ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [EdegRouter] 서비스 설정 upnp/upnp2(igd)/nat-pmp
    끄적끄적 2021. 3. 13. 15:06

    여기서는 EdgeRouter Lite v1.10.11 에서 UPnP 서비스를 추가 제거하는 방법에 대하여 설명한다.

     

    다루는 내용

    - WebUP로 UPnP 서비스 추가하기

    - CLI로 upnp 서비스 추가하기

    - CLI로 upnp2 서비스 추가하기

     

     

    개요


    EdgeRouter-EdgeOS-Feature-Backends 에는 없지만 Edgerouter 에서 제공하는 upnp 서비스는 두가지가 있다

    • linux-igd를 사용한 upnp
      • WebUI 에서 설정 가능
      • UPnP 등록된 포트 현황을 볼 수 없음
    • miniupnpd를 사용한 upnp2
      • CLI 만 설정 가능
      • CLI 상에서 UPnP 등록된 Port Forwarding 현황 볼 수 있음

     

    UPnP라는 서비스는 임의의 어플리케이션이 port를 열수 있게 하므로 보안상 좋지 않으며 되도록이면 수동으로 Port forwarding 룰을 추가하는 것을 추천한다.

     

     

    랜덤으로 포트사용하는 P2P 같은 프로그램 같은 경우 매번 Por Forwarding 하기 어려우므로UPnP 서비를 활성화 해야하는 경우가 있는데 Edgerouter OS에서 UPnP 서비스를 활성화 하는 방법에 대하여 알아보자.

     

    UPnP사용하려면 upnp 보다는 upnp2를 사용하는 것을 추천하는데, upnp서비스는 어떤 포트가 열려있는지 모니터링이안되지만, upnp2는 모니터링이 가능하며 몇가지 부가기능도 지원하기 때문이다.

     

     

    UPnP 설정은 WebUI를 통한 설정과 CLI를 통한 설정 두가지 방법이 있는데, WebUI를 통해서 설정 할 수 있는 UPnP는 linux-igd를 사용한 upnp 만 설정 할 수 있다

    miniupnp를 이용한 UPnP2는 CLI를 통해서만 가능하다.

     

    먼저 linux-igd를 사용한 upnp 설정방법에 대하여 알아보자

     

     

    WebUI로 upnp 서비스 설정


     

     

     

    Edgerouter UPnP 서비스 추가하기

     

     

     

    wizard 탭 > Feature Wizards > UPnP 메뉴로 들어가면 "Set up UPnP Interfaces 항목이 있고 여기에 Add New 버튼을 누르면  "Internal Interface"가 있는데 여기에는 LAN 으로 사용하는 인터페이스를, "External Interface"는 인터넷선이 연결되어 있는 WAN 인터페이스를 입력한다.

     

    인터넷 선이 eth0에 내부 LAN이 eth1에 연결되어 있는 경우 위와 같이 설정하고 Apply를 누른다.

     

    위와 같이 설정하면 eth1의 단말에서 들어온 요청을 응답 받아 eth0으로 들어오는 외부 접속을 Forwarding 하도록 설정하게 된다.

     

    터미널에서 upnpd 가 실행되고 있는것을 확인 할 수 있다.

    $ ps aex | grep upnp
    20532 ?        Sl     0:00 /usr/sbin/upnpd -f eth0 eth1

     

    Service Configre

    $ configure
    [edit]
    
    # show
    firewall    interfaces  service     system
    [edit]
    
    # show service
    dhcp-server  dns          gui          nat          ssh          unms         upnp
    [edit]
    
    # show service upnp
     listen-on eth1 {
         outbound-interface eth0
     }
    [edit]
    

     

    upnp 서비스를 비활성화 하려면 Remove를 눌러 제거하고 Apply를 누르면 된다.

     

     

     

    CLI로 upnp 서비스 설정


    다음가 같이 LAN 인터페이스와 WAN 인터페이스를 입력하여 UPnP를 설정 할 수 있다.

     

    set service upnp listen-on <LAN Interface> outbound-interface <WAN Interface>

    설정과정

    $ configure
    
    # set service upnp listen-on
    eth0  eth1  eth2  imq0  lo
    [edit]
    
    # set service upnp listen-on eth1
    outbound-interface
    [edit]
    
    # set service upnp listen-on eth1 outbound-interface
    eth0  eth1  eth2  lo
    [edit]
    
    # set service upnp listen-on eth1 outbound-interface eth0
    [edit]
    
    # compare
    [edit service upnp]
    +listen-on eth1 {
    +    outbound-interface eth0
    +}
    [edit]
    
    # commit
    [ service upnp listen-on eth1 ]
    Starting upnpd instance for eth1 (eth0)
    
    [edit]
    
    # save
    Saving configuration to '/config/config.boot'...
    Done
    [edit]

     

    upnp 서비스 제거

    $ configure
    
    # delete service upnp 
    
    # compare
    [edit service]
    -upnp2 {
    -    listen-on eth1
    -    nat-pmp disable
    -    secure-mode disable
    -    wan eth0
    -}
    
    # commit
    
    # save
    

     

    CLI로 upnp2 서비스 설정


    upnp2 서비스 추가

     

     WAN과 LAN에 해당하는 Listen-on 인터페이스를 다음과 같이 설정 할 수 있다.

    $ conrigure
    
    # set service upnp2
    Possible completions:
      acl           Access lists
      bit-rate      Bit rate settings
      listen-on     Listen on interface [REQUIRED]
      nat-pmp       Option to enable/disable NAT Port Mapping Protocol
      port          Port for UPnP service
      secure-mode   Option to enable/disable UPnP secure mode
      wan           Out bound WAN interface [REQUIRED]
    [edit]
    
    # set service upnp2 listen-on eth1
    [edit]
    
    # set service upnp2 wan eth0
    [edit]
    
    # set service upnp2 secure-mode enable
    
    # compare
    [edit service]
    +upnp2 {
    +    listen-on eth1
    +    nat-pmp disable
    +    secure-mode enable
    +    wan eth0
    +}
    [edit]
    
    # commit
    [ service upnp2 ]
    Starting the UPNP2 service
    
    [edit]
    
    # save
    Saving configuration to '/config/config.boot'...
    Done
    [edit]
    

    listen-on. WAN, nat-pmp(RFC6886) 와 secure-mode, bit-rate 등을 설정 할 수 있다.

    • listen-on: [필수] upnp 요청이 들어올 Interface, LAN 인터페이스를 설정
    • WAN: [필수] upnp요청으로 부터 Port를 맵핑할 Interface, Internet 라인이 들어오는 인터페이스 설정
    • secure-mode: [필수] 보안을 위해 요청한 단말로만 Forwarding가능 하도록 함, Enable 해준다
    • nat-pmp: upnp와 유사한 기술로 NAT에 Port Mapping을 하는 프로토콜, Apple 제품에서 주로 사용, 필요시 enable 한다.
    • bit-rate: ??? // 속도 제한을 거는 것으로 보이는데 확인 필요
    • acl: 어떤 클라이언트가 매핑을 생성 할 수 있는지를 제한

     nat-pmp를 활성화 하기 위해서는 UPnP 를 활성화 해야함

    ※ nat-pmp는 upnp와 별도의 프로토콜임에도 불구하고 upnp 하부 기능으로 속해 있는건 이상한것

    ※ nat-pmp만 활성화 하기 위해서는 [링크] 를 참조

    - /opt/vyatta/sbin/ubnt-upnp2.pl 파일에서 my $output .= "enable_upnp=yes\n"; 부분 수정 할것

    ※ nat-pmp의 보안 문제로 PCP(Port Control Protocol) 이란게 나옴

    PCP는 nat-pmp의 보안 문제를 해결하고 UPnP-IGD와의 연동도 고려된 프로토콜: Wikipedia:PCP

     

     

    서비스가 추가되면 miniupnpd 가 동작 한다.

    $ ps aex | grep upnp
    23736 ?        Ss     0:00 /usr/sbin/miniupnpd -f /opt/vyatta/etc/miniupnpd.conf -P /var/run/miniupnpd.pid

     

    upnp2 서비스 현황 보기

    $ show upnp2 rules
    Firewall pin holes
     pkts bytes target     prot opt in     out     source               destination
       25  1148 ACCEPT     tcp  --  *      *       0.0.0.0/0            192.168.1.39         tcp dpt:31452
      355 96155 ACCEPT     udp  --  *      *       0.0.0.0/0            192.168.1.39         udp dpt:31452
    
    NAT port forwards
     pkts bytes target     prot opt in     out     source               destination
        8   468 DNAT       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            tcp dpt:31452 to:192.168.1.39:31452
        8   826 DNAT       udp  --  *      *       0.0.0.0/0            0.0.0.0/0            udp dpt:31452 to:192.168.1.39:31452

     

    upnp2 서비스 제거

    $ configure
    
    # delete service upnp2
    
    # commit
    
    # save
    

     

    ※ NAT-PMP 취약점: blog.rapid7.com/2014/10/21/r7-2014-17-nat-pmp-implementation-and-configuration-vulnerabilities/

    ※ UPNP 보안: https://www.lepide.com/blog/what-is-upnp-and-is-it-safe/ 

    728x90
    반응형

    댓글

Designed by Tistory.