標籤:tail vmw 結構 版本 enable remote .net div 虛擬網卡
一、 基礎環境
使用VmWare虛擬兩台Linux機器。CentOS 7,Linux核心如下:
4.5.3-1.el7.elrepo.x86_64
如果核心版本太低,是不支援VxLan的。可以使用一下命令進行核心升級
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[plain] view plain copy
- rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
- yum --enablerepo=elrepo-kernel install kernel-ml-devel kernel-ml -y
升級後重啟選擇新核心。
二、 組網圖
兩台虛機VM1和VM2,eth2為虛機上的網卡。vxlan10是建立的虛擬網卡,用來處理vxlan。veth1和veth0是建立的一對虛擬口。br-vx是建立的橋接器。
三、 配置命令
VM1:
[html] view plain copy
- #建立橋接器br-vx並使其up
- brctl addbr br-vx
- ip link set br-vx up
- #增加一個類型為vxlan,vni-id為100的,名字為vxlan10的虛擬網卡,指明對端地址為192.168.233.190,
- #(此地址為VM2的eth2的地址)出介面為本端的eth2
- ip link add vxlan10 type vxlan id 100 remote 192.168.233.190 dstport 4789 dev eth2
- ip link set vxlan10 up
- #把vxlan10加入到橋接器中
- brctl addif br-vx vxlan10
- #建立一對虛擬網卡,設定其中的veth0的地址為192.167.1.6,並把veth1綁到橋接器br-vx中。從veth0
- #發出的報文將會發給veth1,由於veth1在橋接器中,會被進入到vxlan10中通過vxlan隧道發送給對端
- ip link add type veth
- ifconfig veth0 192.167.1.6/24 up
- ifconfig veth0 mtu 1450
- ifconfig veth1 up
- ifconfig veth1 mtu 1450
- brctl addif br-vx veth1
VM2:
[html] view plain copy
- #建立橋接器br-vx並使其up
- brctl addbr br-vx
- ip link set br-vx up
- #增加一個類型為vxlan,vni-id為100的,名字為vxlan10的虛擬網卡,指明對端地址為192.168.233.180,
- #(此地址為VM2的eth2的地址)出介面為本端的eth2
- ip link add vxlan10 type vxlan id 100 remote 192.168.233.180 dstport 4789 dev eth2
- ip link set vxlan10 up
- #把vxlan10加入到橋接器中
- brctl addif br-vx vxlan10
- #建立一對虛擬網卡,設定其中的veth0的地址為192.167.1.7,並把veth1綁到橋接器br-vx中。從veth0
- #發出的報文將會發給veth1,由於veth1在橋接器中,會被進入到vxlan10中通過vxlan隧道發送給對端
- ip link add type veth
- ifconfig veth0 192.167.1.7/24 up
- ifconfig veth0 mtu 1450
- ifconfig veth1 up
- ifconfig veth1 mtu 1450
- brctl addif br-vx veth1
四、 驗證
搭建好後,可以在VM1上使用ping命令來驗證:VM1: ping 192.167.1.7,通過tcpdump抓報文看結構。
參考文章:http://blog.csdn.net/xingyeping/article/details/51353321
使用CentOS Linux Bridge搭建Vxlan環境