ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

openvswitch 使用记录(二)--vlan 环境搭建(2)

2020-02-23 22:02:16  阅读:372  来源: 互联网

标签:seq ping vlan bytes openvswitch 192.168 64 icmp 搭建


 

host2上ovs-br2创建过程:

 

初始状态

[root@localhost out]# ovs-vsctl show

06e749d9-0c1e-4b72-bcbc-94db1b7111dd

ovs_version: "2.12.0"

 

1、在host2上添加ovs-br2网桥

[root@localhost out]# ovs-vsctl add-br ovs-br2

2、添加端口(物理网卡)到ovs-br2上

[root@localhost out]# ovs-vsctl add-port ovs-br2 enp6s0

 

注意:此时网络可能无法通往外网如需上网做如下处理:

[root@localhost out]# ifconfig enp6s0 0

[root@localhost out]# killall dhclient

[root@localhost out]#ifconfig ovs-br2 up

[root@localhost out]#dhclient ovs-br2

查看当前ovs网桥信息

[root@localhost out]# ovs-vsctl show

06e749d9-0c1e-4b72-bcbc-94db1b7111dd

    Bridge "ovs-br2"

        Port "ovs-br2"

            Interface "ovs-br2"

                type: internal

        Port "enp6s0"

            Interface "enp6s0"

ovs_version: "2.12.0"

3、向ovs-br2中添加端口p10 并将vid设置为10

[root@localhost out]# ovs-vsctl add-port ovs-br2 p10 tag=10 -- set interface p10 type=internal

4、向ovs-br2中添加端口p20 并将vid设置为20

[root@localhost out]# ovs-vsctl add-port ovs-br2 p20 tag=20 -- set interface p20 type=internal

查看此时网桥信息 此时已经添加2个vlan端口,

[root@localhost out]# ovs-vsctl show

06e749d9-0c1e-4b72-bcbc-94db1b7111dd

    Bridge "ovs-br2"

        Port "ovs-br2"

            Interface "ovs-br2"

                type: internal

        Port "p20"

            tag: 20

            Interface "p20"

                type: internal

        Port "enp6s0"

            Interface "enp6s0"

        Port "p10"

            tag: 10

            Interface "p10"

                type: internal

ovs_version: "2.12.0"

 

注意:Port "enp6s0" 默认为trunk端口,允许所有的vlan id通过

5、添加vm3网卡模式如下图,选择p10

下图为vm3网卡

 

配置ip地址

 

 

配置vm3的eth0 ip 为 192.168.1.4

[loongson@localhost ~]$ ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.4  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::5054:ff:fef6:d092  prefixlen 64  scopeid 0x20<link>

        ether 52:54:00:f6:d0:92  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 20  bytes 2296 (2.2 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

6、添加vm4网卡模式如下图,选择p10

 

 

 

ip地址如下

[loongson@localhost ~]$ ifconfig eth0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.5  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::5054:ff:fef0:dcf  prefixlen 64  scopeid 0x20<link>

        ether 52:54:00:f0:0d:cf  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 18  bytes 1292 (1.2 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

7、 添加vm5网卡模式如下图,选择p20

 

 

 

查看ip地址

 

[loongson@localhost ~]$ ifconfig eth0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.6  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::5054:ff:fe81:9971  prefixlen 64  scopeid 0x20<link>

        ether 52:54:00:81:99:71  txqueuelen 1000  (Ethernet)

        RX packets 2  bytes 84 (84.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 19  bytes 1354 (1.3 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

 

8、 添加vm6网卡模式如下图,选择p20

 

 

 

[loongson@localhost ~]$ ifconfig eth0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.7  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::5054:ff:fe95:f3fe  prefixlen 64  scopeid 0x20<link>

        ether 52:54:00:95:f3:fe  txqueuelen 1000  (Ethernet)

        RX packets 2  bytes 84 (84.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 19  bytes 1354 (1.3 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

 

9、验证结果

vm3---ping--->vm1

loongson@localhost ~]$ ping 192.168.1.2

PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.

64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=73.0 ms

64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=34.7 ms

64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=35.4 ms

64 bytes from 192.168.1.2: icmp_seq=4 ttl=64 time=34.8 ms

vm3---ping--->vm4

[loongson@localhost ~]$ ping 192.168.1.5

PING 192.168.1.5 (192.168.1.5) 56(84) bytes of data.

64 bytes from 192.168.1.5: icmp_seq=1 ttl=64 time=1.32 ms

64 bytes from 192.168.1.5: icmp_seq=2 ttl=64 time=1.11 ms

64 bytes from 192.168.1.5: icmp_seq=3 ttl=64 time=1.24 ms

64 bytes from 192.168.1.5: icmp_seq=4 ttl=64 time=1.10 ms

 

vm3---ping---->vm5、vm6

[loongson@localhost ~]$ ping 192.168.1.6

PING 192.168.1.6 (192.168.1.6) 56(84) bytes of data.

From 192.168.1.4 icmp_seq=1 Destination Host Unreachable

From 192.168.1.4 icmp_seq=2 Destination Host Unreachable

From 192.168.1.4 icmp_seq=3 Destination Host Unreachable

From 192.168.1.4 icmp_seq=4 Destination Host Unreachable

From 192.168.1.4 icmp_seq=5 Destination Host Unreachable

From 192.168.1.4 icmp_seq=6 Destination Host Unreachable

^C

--- 192.168.1.6 ping statistics ---

7 packets transmitted, 0 received, +6 errors, 100% packet loss, time 6033ms

pipe 3

[loongson@localhost ~]$ ping 192.168.1.7

PING 192.168.1.7 (192.168.1.7) 56(84) bytes of data.

From 192.168.1.4 icmp_seq=1 Destination Host Unreachable

From 192.168.1.4 icmp_seq=2 Destination Host Unreachable

From 192.168.1.4 icmp_seq=3 Destination Host Unreachable

^C

 

 

同样vm4---ping---->vm1、vm4

[loongson@localhost ~]$ ifconfig eth0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.5  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::5054:ff:fef0:dcf  prefixlen 64  scopeid 0x20<link>

        ether 52:54:00:f0:0d:cf  txqueuelen 1000  (Ethernet)

        RX packets 55  bytes 4602 (4.4 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 40  bytes 3096 (3.0 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[loongson@localhost ~]$ ping 192.168.1.2

PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.

64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=72.1 ms

64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=34.8 ms

64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=35.0 ms

^C

--- 192.168.1.2 ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2000ms

rtt min/avg/max/mdev = 34.892/47.360/72.132/17.516 ms

[loongson@localhost ~]$ ping 192.168.1.4

PING 192.168.1.4 (192.168.1.4) 56(84) bytes of data.

64 bytes from 192.168.1.4: icmp_seq=1 ttl=64 time=1.10 ms

64 bytes from 192.168.1.4: icmp_seq=2 ttl=64 time=2.10 ms

64 bytes from 192.168.1.4: icmp_seq=3 ttl=64 time=1.07 ms

^C

--- 192.168.1.4 ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2002ms

rtt min/avg/max/mdev = 1.079/1.428/2.102/0.477 ms

 

 

 

vm5---ping--->vm2、vm6  可以通,ping vm1 vm3 vm4不通

[loongson@localhost ~]$ ping 192.168.1.3

PING 192.168.1.3 (192.168.1.3) 56(84) bytes of data.

64 bytes from 192.168.1.3: icmp_seq=1 ttl=64 time=36.4 ms

64 bytes from 192.168.1.3: icmp_seq=2 ttl=64 time=34.8 ms

64 bytes from 192.168.1.3: icmp_seq=3 ttl=64 time=35.2 ms

^C

--- 192.168.1.3 ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2002ms

rtt min/avg/max/mdev = 34.830/35.495/36.430/0.697 ms

[loongson@localhost ~]$ ping 192.168.1.7

PING 192.168.1.7 (192.168.1.7) 56(84) bytes of data.

64 bytes from 192.168.1.7: icmp_seq=1 ttl=64 time=1.96 ms

64 bytes from 192.168.1.7: icmp_seq=2 ttl=64 time=0.784 ms

^C

--- 192.168.1.7 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1001ms

rtt min/avg/max/mdev = 0.784/1.375/1.967/0.592 ms

 

vm5   ---》ping vm1 vm3 vm4不通

[loongson@localhost ~]$ ping 192.168.1.2

PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.

From 192.168.1.6 icmp_seq=1 Destination Host Unreachable

From 192.168.1.6 icmp_seq=2 Destination Host Unreachable

From 192.168.1.6 icmp_seq=3 Destination Host Unreachable

From 192.168.1.6 icmp_seq=4 Destination Host Unreachable

^C

--- 192.168.1.2 ping statistics ---

5 packets transmitted, 0 received, +4 errors, 100% packet loss, time 4000ms

pipe 4

[loongson@localhost ~]$ ping 192.168.1.4

PING 192.168.1.4 (192.168.1.4) 56(84) bytes of data.

From 192.168.1.6 icmp_seq=1 Destination Host Unreachable

From 192.168.1.6 icmp_seq=2 Destination Host Unreachable

From 192.168.1.6 icmp_seq=3 Destination Host Unreachable

^C

--- 192.168.1.4 ping statistics ---

5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4023ms

pipe 3

[loongson@localhost ~]$ ping 192.168.1.5

PING 192.168.1.5 (192.168.1.5) 56(84) bytes of data.

From 192.168.1.6 icmp_seq=1 Destination Host Unreachable

From 192.168.1.6 icmp_seq=2 Destination Host Unreachable

From 192.168.1.6 icmp_seq=3 Destination Host Unreachable

From 192.168.1.6 icmp_seq=4 Destination Host Unreachable

^C

--- 192.168.1.5 ping statistics ---

5 packets transmitted, 0 received, +4 errors, 100% packet loss, time 4001ms

pipe 4

 

 

vm6---ping--->vm2、vm5  可以通,ping vm1 vm3 vm4不通

[loongson@localhost ~]$ ifconfig eth0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.7  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::5054:ff:fe95:f3fe  prefixlen 64  scopeid 0x20<link>

        ether 52:54:00:95:f3:fe  txqueuelen 1000  (Ethernet)

        RX packets 39  bytes 2154 (2.1 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 36  bytes 2424 (2.3 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

[loongson@localhost ~]$ ping 192.168.1.3

PING 192.168.1.3 (192.168.1.3) 56(84) bytes of data.

64 bytes from 192.168.1.3: icmp_seq=1 ttl=64 time=35.9 ms

64 bytes from 192.168.1.3: icmp_seq=2 ttl=64 time=34.7 ms

^C

--- 192.168.1.3 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1001ms

rtt min/avg/max/mdev = 34.701/35.304/35.907/0.603 ms

[loongson@localhost ~]$ ping 192.168.1.6

PING 192.168.1.6 (192.168.1.6) 56(84) bytes of data.

64 bytes from 192.168.1.6: icmp_seq=1 ttl=64 time=0.973 ms

64 bytes from 192.168.1.6: icmp_seq=2 ttl=64 time=1.18 ms

^C

--- 192.168.1.6 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1001ms

rtt min/avg/max/mdev = 0.973/1.076/1.180/0.108 ms

[loongson@localhost ~]$ ping 192.168.1.2

PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.

From 192.168.1.7 icmp_seq=1 Destination Host Unreachable

From 192.168.1.7 icmp_seq=2 Destination Host Unreachable

From 192.168.1.7 icmp_seq=3 Destination Host Unreachable

^C

--- 192.168.1.2 ping statistics ---

4 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3015ms

pipe 3

[loongson@localhost ~]$ ping 192.168.1.4

PING 192.168.1.4 (192.168.1.4) 56(84) bytes of data.

From 192.168.1.7 icmp_seq=1 Destination Host Unreachable

From 192.168.1.7 icmp_seq=2 Destination Host Unreachable

From 192.168.1.7 icmp_seq=3 Destination Host Unreachable

^C

--- 192.168.1.4 ping statistics ---

4 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3014ms

pipe 3

[loongson@localhost ~]$ ping 192.168.1.5

PING 192.168.1.5 (192.168.1.5) 56(84) bytes of data.

From 192.168.1.7 icmp_seq=1 Destination Host Unreachable

From 192.168.1.7 icmp_seq=2 Destination Host Unreachable

From 192.168.1.7 icmp_seq=3 Destination Host Unreachable

^C

--- 192.168.1.5 ping statistics ---

5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4022ms

pipe 3

 

 

参考资料:

http://docs.openvswitch.org/en/latest/howto/vlan/

sunshine_xiaoxiaoyan 发布了13 篇原创文章 · 获赞 2 · 访问量 3233 私信 关注

标签:seq,ping,vlan,bytes,openvswitch,192.168,64,icmp,搭建
来源: https://blog.csdn.net/wangyangzhizunwudi/article/details/104468102

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有