개요
VXLAN으로 인해 가능한 것
VXLAN은 가상 머신들이 여러 L3 네트워크에 걸쳐서 동일한 논리적 네트워크상에 있게 만들 수 있게 해줍니다.
따라서 L3 네트워크 상에서(IP/UDP 기반) L2 세그먼트를 구성할 수 있게 됩니다.
또한 기존 VLAN 기반의 네트워크보다 훨씬 많은 L2 세그먼트를 유지할 수 있게 됩니다.
*VTEP(VXLAN Tunnel Endpoint)는 가상 머신이 통신할 때 발생하는 트래픽(L2)을 VXLAN 헤더로 캡슐화/역캡슐화하는 기능을 합니다.
*리눅스에서는 기본값으로 UDP/8472를 VXLAN용으로 사용하는데, IANA 표준은 UDP/4789입니다.
VXLAN 동작
A. MAC=111인 VM은 2.2.2.2와 통신하고 싶지만 ARP 테이블에 주소가 없다. 따라서 ARP Request를 브로드캐스트한다.
B. vSwitch가 멀티캐스트를 통해 ARP Request를 모든 VTEP들에 뿌린다. ARP Request가 온 VM1의 정보(VNI, MAC, IP등)를 테이블에 등록한다.
C. 다른 호스트의 vSwitch가 역캡슐화하고 VM2로도 브로드캐스트한다. ARP Request가 온 VM1의 정보를 테이블에 등록한다.
D. VM2는 ARP Request를 받고 ARP Table에 등록한다. 그 다음 ARP Response를 MAC=111에게 유니캐스트한다.
E. 다른 호스트의 vSwitch가 ARP Response를 유니캐스트로 원래 호스트로 전송한다.
F. 원래 호스트의 vSwitch는 ARP Response를 역캡슐화하고 VM1로 유니캐스트한다. ARP Response가 온 VM2의 정보를 테이블에 등록한다.
G. VM1은 ARP Response를 받고 ARP Table에 등록한다.
H. 이후 두 VM은 유니캐스트로 통신하게 된다.
리눅스 브릿지와 iproute2를 사용한 VXLAN 예제
*목표: IP 대역이 동일한 kim 서버와 lee 서버를 VXLAN을 이용해서 독립된 세그먼트로 분할
*호스트 구성
Router: Debian 9.4, CLI, pim daemon running
LXC1: Debian 9.4, GNOME, network-manager-gnome, lxc
LXC2: Debian 9.4, GNOME, network-manager-gnome, lxc
Containers: Debian 9.4 minbase(debootstrap)
A. Router Configuration
Install pim daemon.
apt-get install pimd
B. LXC1 Configuration(same config for LXC2, except the name of containers and ip addresses.)
Initial configuration of LXC and APT repository
apt-get install lxc nginx
mount /dev/dvd /var/www/html
Change variable MIRROR to http://localhost/ AND add “--no-check-gpg \” at the end of debootstrap command from /usr/share/lxc/templates/lxc-debian.
Create VXLAN both vxlan10 and 20, br-10 and 20.
ip link add vxlan 10 type vxlan id 10 group 239.1.1.1 dstport 0 dev ens33
//Create a vxlan port with VNI 10, use device ens33 to multicast traffic using group 239.1.1.1 with default dst port
ip link add br-10 type bridge
//Create a bridge which will bridge the vxlan port
ip link set vxlan10 master br-10
ip link set vxlan10 up
ip link set br-10 up
Set container’s network interfaces. (same for lee-srv1, except the bridge’s name)
vi /var/lib/lxc/kim-srv1/config
lxc.network.type = veth
//virtual ethernet bridge connected to lxc.network.link.
lxc.network.link = br-10 //master interface on real host.
lxc.network.veth.pair = kim-srv1-eth0 //name of interface on real host.
Create kim and lee’s LXC containers:
lxc-create –t debian –n kim-srv1 -- -r stretch
lxc-create –t debian –n lee-srv1 -- -r stretch
lxc-start –n kim-srv1 -d
lxc-start –n lee-srv1 –d
Change root password of containers.
lxc-attach –n kim-srv1 passwd
Enter new UNIX password:
Retype new UNIX password:
lxc-attach –n lee-srv1 passwd
Enter new UNIX password:
Retype new UNIX password:
Set ip address for containers.
lxc-console –n kim-srv1
cat > /etc/network/interfaces
auto eth0
iface eth0 inet static
address 1.1.1.1/24
^C
ifdown eth0
ifup eth0
^aq
lxc-console –n lee-srv1
cat > /etc/network/interfaces
auto eth0
iface eth0 inet static
address 1.1.1.1/24
^C
ifdown eth0
ifup eth0
^aq
Increase TTL of multicast traffic by 1.
iptables –t mangle –A OUTPUT –d 239.1.1.1 –j TTL –ttl-inc 1
C. Test!
on lee-srv1 on LXC1 host.
lxc-console –n lee-srv1
ssh user@1.1.1.2
ECDSA key fingerprit is … Are you want to continue connecting (yes/no)? yes
user@1.1.1.2’s password:
user@lee-srv2:~$
참고
- https://ilearnedhowto.wordpress.com/2017/02/16/how-to-create-overlay-networks-using-linux-bridges-and-vxlans/
- https://linuxcontainers.org/ko/lxc/manpages/man5/lxc.container.conf.5.html
- http://troglobit.github.io/howto/multicast/
- http://youngmind.tistory.com/entry/Network-Overlay-VXLAN-%EB%B6%84%EC%84%9D-3?category=394664
- http://www.yellow-bricks.com/2012/11/02/vxlan-use-cases/