vxlan

2016/10/05

vxlan 学习&练习,控制器

典型组网

场景一:

vxlan1

配置参考


  ip link add tap1 type veth peer name vtap1
  ip link add tap2 type veth peer name vtap2
  ip netns add ns1
  ip netns add ns2
  ip link set vtap1 netns ns1
  ip link set vtap2 netns ns2
  ip netns exec ns1 ifconfig lo up
  ip netns exec ns1 ifconfig vtap1 up
  ip netns exec ns1 ifconfig vtap1 1.1.1.2/24
  ip netns exec ns2 ifconfig lo up
  ip netns exec ns2 ifconfig vtap2 up
  ip netns exec ns2 ifconfig vtap2 1.1.1.3/24
  ovs-vsctl add-br br0
  ifconfig tap1 up
  ifconfig tap2 up
  ovs-vsctl add-port br0 tap1
  ovs-vsctl add-port br0 tap2
  ovs-vsctl add-port br0 tap2 tag=3
  ovs-vsctl add-port br0 vxlan -- set interface vxlan type=vxlan options:remote_ip=192.168.2.220 options:key=4 options:dst_port=9999

vxlan_ovs

场景二:二层通讯,同vxlan的vni,报文vlan相同,remote_ip对指定IP地址

sameVNIVLAN

配置

  • host1:
    host1

  • host2:
    host2

  • 虚拟机1.1.1.2 ping 1.1.1.9 时,虚拟机发送arp请求,在经过vxlan接口时封装vxlan报文头,在host2的eth0上抓包,为UDP报文目的IP为remoteIP地址,vni就是配置的值

场景三:二层通信,同vxlan的vni,报文vlan不同,remote_ip只向指定IP地址

  • 报文无法通信
  • 配置:
host1:
root@ubuntuwww:~# ovs-vsctl show
c6e9407c-a362-41da-8aee-cc4fcc533d03
    Bridge "br0"
        Port "tap2"
            tag: 3
            Interface "tap2"
        Port vxlan
            Interface vxlan
                type: vxlan
                options: {dst_port="9999", key="4", remote_ip="192.168.2.180"}
        Port "br0"
            Interface "br0"
                type: internal
        Port "tap1"
            tag: 6
            Interface "tap1"


host2:
root@hostubuntu1:~# ovs-vsctl show
bcacb6dd-88d1-4798-b363-b4e498f5aeca
    Bridge "br0"
        Port vxlan
            Interface vxlan
                type: vxlan
                options: {dst_port="9999", key="4", remote_ip="192.168.2.220"}
        Port "br0"
            Interface "br0"
                type: internal
        Port "tap2"
            tag: 3
            Interface "tap2"
        Port "tap1"
            tag: 3
            Interface "tap1"

场景四:【vxlan网关】二层网关,两个虚拟机一个带走vxlan,一个走普通二层网络vlan,同网段

场景五:linux bridge方式,对端为ovs,remote只想对端同上

root@ubuntuwww:~# brctl show
bridge name    	bridge id      		STP enabled    	interfaces
br0    		8000.0e2ebbe6ade2      	no     		tap1
       							vxlan

13: vxlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master br0 state UNKNOWN mode DEFAULT group default
    link/ether ae:20:a8:f8:eb:6c brd ff:ff:ff:ff:ff:ff promiscuity 1
    vxlan id 5 remote 192.168.2.66 dev eth0 port 32768 61000 ageing 300

场景六:ovs为组播,linux bridge 为组播

ovs端配置:

root@ubuntuwww:~# ovs-vsctl show
c6e9407c-a362-41da-8aee-cc4fcc533d03
    Bridge "br0"
        Port "tap2"
            tag: 3
            Interface "tap2"
        Port "vxlan0"
            Interface "vxlan0"
        Port "tap1"
            tag: 6
            Interface "tap1"
        Port "br0"
            Interface "br0"
                type: internal
        Port "tap3"
            Interface "tap3"

vxlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master ovs-system state UNKNOWN mode DEFAULT group default
    link/ether 06:90:78:59:f2:82 brd ff:ff:ff:ff:ff:ff promiscuity 1
    vxlan id 5 group 239.1.1.1 dev eth0 port 32768 61000 ageing 300

root@ubuntuwww:~# ip netns exec ns3 ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:85 errors:0 dropped:0 overruns:0 frame:0
          TX packets:85 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:9520 (9.5 KB)  TX bytes:9520 (9.5 KB)

vtap3     Link encap:Ethernet  HWaddr 2a:e0:04:d1:7a:5b
          inet addr:3.3.3.3  Bcast:3.3.3.255  Mask:255.255.255.0
          inet6 addr: fe80::28e0:4ff:fed1:7a5b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3201 errors:0 dropped:0 overruns:0 frame:0
          TX packets:153 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:140674 (140.6 KB)  TX bytes:11498 (11.4 KB)

linux bridge:
root@route:~# brctl show br0
bridge name    	bridge id      		STP enabled    	interfaces
br0    		8000.164dff898c7c      	no     		tap1
       							vxlan0
vxlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master br0 state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether be:a7:b6:48:cc:1d brd ff:ff:ff:ff:ff:ff promiscuity 1
    vxlan id 5 group 239.1.1.1 dev eth0 port 0 0 ageing 300


t@route:~# ip netns exec ns1 ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

vtap1     Link encap:Ethernet  HWaddr fe:c2:ac:2f:2b:b6
          inet addr:3.3.3.1  Bcast:3.3.3.255  Mask:255.255.255.0
          inet6 addr: fe80::fcc2:acff:fe2f:2bb6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:164 errors:0 dropped:0 overruns:0 frame:0
          TX packets:164 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:15656 (15.6 KB)  TX bytes:15656 (15.6 KB)

3.3.3.3-->3.3.3.1 是可以ping通的

七、vxlan头 + (普通ip报文,不带vlan头) 与 vlan 报文通信

八、假设192.168.2.62 是之前网络存在的配置vlan网关的交换机。新的需求,把3.3.3.3的虚拟由vlan类型修改为只带vxlan报文头的类型,跟1.1.1.2的报文进行 vxlan和vlan的通信。

引用

Post Directory