EdgeRouter - GRE 터널을 활용한 레이어-2 브릿지 ============================================= download at 2017-02-21T22:52:37Z `origin `_ Overview -------- -------------- 이 문서는 레이어 2의 제네릭 라우팅 캡슐화 (generic routing encapsulation, GRE)를 2개의 분리된 라우터를 터널링 하는 방법에 대하여 서술합니다.   .. raw:: html
|image0| .. rubric:: Sample LANs bridged over GRE tunnel using two EdgeRouters. :name: sample-lans-bridged-over-gre-tunnel-using-two-edgerouters.   .. raw:: html
.. raw:: html
.. raw:: html
위의 다이어그램은 인터넷을 통한 GRE 터널을 나타내고 있습니다. GRE는 암호화 기능을 제공하지 않기 때문에 퍼블릭 네트워크에 사용을 한다면 IPsec 터널을 통해서 GRE 터널을 보호해야 할 것입니다. 이러한 작업을 위하여 다음을 가정합니다:   :: R1 WAN 인터페이스는 eth1이고 주소는 15.0.0.1/24 이며, LAN 인터페이스는 eth0 서브넷으로 100.0.0.0/24 로 브릿징이 설정되었다고 가정합니다. R2 WAN 인터페이스는 eth1이고, 주소는 15.0.0.2/24이며 LAN 인터페이스는 eth0이라고 가정합니다. 먼저 GRE 터널을 생성합니다:   :: ubnt@R1:~$ configure [edit] ubnt@R1# set interfaces tunnel tun0 encapsulation gre-bridge [edit] ubnt@R1# set interfaces tunnel tun0 local-ip 15.0.0.1 [edit] ubnt@R1# set interfaces tunnel tun0 remote-ip 15.0.0.2 [edit] ubnt@R1# commit [edit] Note: 터널 캡슐화는 **gre** 가 아니라 **gre-bridge** 입니다. 브릿지 인터페이스를 생성하고 eht0과 tun0을 브릿지 그룹에 추가합니다.   :: ubnt@R1:~$ configure [edit] ubnt@R1# set interfaces bridge br0 [edit] ubnt@R1# set interfaces ethernet eth0 bridge-group bridge br0 [edit] ubnt@R1# set interfaces tunnel tun0 bridge-group bridge br0 [edit] ubnt@R1# commit [ interfaces ethernet eth0 bridge-group ] Adding interface eth0 to bridge br0 [edit] ubnt@R1# exit; save Warning: configuration changes have not been saved. exit 이제 PC에서 R1 LAN 100.0.0.100에서 R2 LAN 100.0.0.100d으로 핑을 보내보면, R2에서 패킷이 어떻게 처리되는지 확인해봅시다: 패킷을 살펴보면 encaps - eth:ip:gre:eth:ip:icmp:data 순서로 값을 가집니다. :: Ethernet II, Src: dc:9f:db:17:12:35 (dc:9f:db:17:12:35), Dst: dc:9f:db:29:05:f6 (dc:9f:db:29:05:f6) Destination: dc:9f:db:29:05:f6 (dc:9f:db:29:05:f6) Address: dc:9f:db:29:05:f6 (dc:9f:db:29:05:f6) Source: dc:9f:db:17:12:35 (dc:9f:db:17:12:35) Type: IP (0x0800) Internet Protocol, Src: 15.0.0.2 (15.0.0.2), Dst: 15.0.0.1 (15.0.0.1) Version: 4 Header length: 20 bytes Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00) Total Length: 1500 Identification: 0x0000 (0) Flags: 0x02 (Don't Fragment) Fragment offset: 0 Time to live: 64 Protocol: GRE (0x2f) Header checksum: 0x16f1 [correct] Source: 15.0.0.2 (15.0.0.2) Destination: 15.0.0.1 (15.0.0.1) Generic Routing Encapsulation (Transparent Ethernet bridging) Flags and version: 0000 Protocol Type: Transparent Ethernet bridging (0x6558) Ethernet II, Src: Ubiquiti_07:07:21 (00:15:6d:07:07:21), Dst: dc:9f:db:17:13:8e (dc:9f:db:17:13:8e) Destination: dc:9f:db:17:13:8e (dc:9f:db:17:13:8e) Address: dc:9f:db:17:13:8e (dc:9f:db:17:13:8e) Source: Ubiquiti_07:07:21 (00:15:6d:07:07:21) Address: Ubiquiti_07:07:21 (00:15:6d:07:07:21) Type: IP (0x0800) Internet Protocol, Src: 100.0.0.101 (100.0.0.101), Dst: 100.0.0.100 (100.0.0.100) Version: 4 Header length: 20 bytes Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00) Total Length: 1462 Identification: 0x0000 (0) Flags: 0x02 (Don't Fragment) Fragment offset: 0 Time to live: 64 Protocol: ICMP (0x01) Header checksum: 0x6c7e [correct] Source: 100.0.0.101 (100.0.0.101) Destination: 100.0.0.100 (100.0.0.100) Internet Control Message Protocol Type: 8 (Echo (ping) request) Code: 0 () Checksum: 0xe7da [correct] Identifier: 0x0e90 Sequence number: 1 (0x0001) Data (1434 bytes) gre-bridge 인터페이스는 38 바이트(gre 4, eth 14, ip 20)를 헤더에 추가해서 터널 인터페이스가 자동으로 mtu 값을 1500에서 1462로 감소하도록 합니다: :: ubnt@R1:~$ show interfaces tunnel tun0 tun0@NONE: mtu 1462 qdisc pfifo_fast state UNKNOWN qlen 1000 link/ether 12:5b:3a:c1:4a:f1 brd ff:ff:ff:ff:ff:ff inet6 fe80::105b:3aff:fec1:4af1/64 scope link valid_lft forever preferred_lft forever RX: bytes packets errors dropped overrun mcast 3186 34 0 0 0 0 TX: bytes packets errors dropped carrier collisions 3166 34 0 0 0 0 .. rubric:: L2 Bridge over Openvpn :name: l2-bridge-over-openvpn 같은 방식으로 openvpn 사이트-투-사이트 터널도 브릿징이 가능합니다. :: ubnt@R1:~$ configure [edit] ubnt@R1# delete interfaces tunnel [edit] ubnt@R1# commit [edit] :: ubnt@R1# set interfaces openvpn vtun0 mode site-to-site [edit] ubnt@R1# set interfaces openvpn vtun0 remote-host 15.0.0.2 [edit] ubnt@R1# set interfaces openvpn vtun0 shared-secret-key-file /config/auth/secret [edit] ubnt@R1# set interfaces openvpn vtun0 bridge-group bridge br0 [edit] ubnt@R1# commit [edit] ubnt@R1# save Saving configuration to '/config/config.boot'... Done [edit] ubnt@R1# exit exit openvpn mtu 감소 값은 기존의 ethernet 14 바이트, ip 20 바이트와 openvpn이 UDP (8 바이트)를 쓰느냐, TCP (20 바이트)를 쓰느냐에 따라서 값이 달라집니다. .. raw:: html
.. raw:: html
.. raw:: html
.. raw:: html
.. |image0| image:: /hc/en-us/article_attachments/202824060/topology.png