目录
一:配置team机制中activebackup并验证
I:在Vmware点击“虚拟机”中的“设置”开启两块网卡:
II:配置
1:查看网卡:
[root@rhcsa ~]# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.44.3 netmask 255.255.255.0 broadcast 192.168.44.255
inet6 fe80::cad5:fac9:6edc:17c4 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:f0:ec:e5 txqueuelen 1000 (Ethernet)
RX packets 4321 bytes 1338275 (1.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2784 bytes 337336 (329.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens224: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 00:0c:29:f0:ec:ef txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 96 bytes 10560 (10.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 96 bytes 10560 (10.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:8b:7c:80 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
2:配置网卡2:
[root@rhcsa ~]# nmcli c modify ens224 ipv4.addresses 192.168.44.100 ipv4.gateway 192.168.44.2 ipv4.dns 8.8.8.8 ipv4.method manual
3:创建team连接以及team的虚拟网卡'{"runner": {"name": "activebackup", "hwaddr_policy": "by_active"}}'
将两块网卡绑定在team上,team就是我们对外的网卡以及连接
[root@rhcsa ~]# nmcli c add type team con-name team_con ifname team_dev ipv4.addresses 192.168.44.10/24 \
> ipv4.gateway 192.168.44.2 ipv4.dns 8.8.8.8 ipv4.method manual config '{"runnner":{"name":"activebackup","hwaddr_policy": "by_active"}}'
Connection 'team_con' (54756f19-9e54-4a47-9449-cb4edd0ab785) successfully added.
[root@rhcsa ~]# nmcli c add type team-slave con-name team_con_1 ifname ens160 master team_dev
Connection 'team_con_1' (14fd753b-8a3a-4c2b-99fd-91b16fb9105f) successfully added.
[root@rhcsa ~]# nmcli c add type team-slave con-name team_con_2 ifname ens224 master team_dev
Connection 'team_con_2' (07e781d1-74a1-43ab-bb7c-74de81ee04f0) successfully added.
[root@rhcsa ~]# nmcli c up team_con_1 team_con_2
4:激活: 先激活team_con, 然后再激活team_dev
[root@rhcsa ~]# nmcli c up team_con_1 team_con_2
[root@rhcsa ~]# nmcli c up team_con
5:查询
此时两块网卡与team_dev的Mac地址相同,且没有IPV4地址 ;只有team_dev有IPV4地址。
此时两块网卡的状态都为up。
[root@rhcsa ~]# teamdctl team_dev state
setup:
runner: roundrobin
ports:
ens160
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
ens224
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
6:测试:
[root@rhcsa ~]# ping www.baidu.com
\PING www.wshifen.com (103.235.46.39) 56(84) bytes of data.
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=1 ttl=128 time=63.5 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=2 ttl=128 time=61.2 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=3 ttl=128 time=58.8 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=4 ttl=128 time=59.4 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=5 ttl=128 time=65.5 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=6 ttl=128 time=105 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=7 ttl=128 time=306 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=8 ttl=128 time=75.1 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=9 ttl=128 time=62.6 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=10 ttl=128 time=95.6 ms
7:用wireshark抓包
team此时就是我们对外的网卡以及连接
二:其他状态
2.配置team机制中roundrobin
3.配置team机制中loadbalance
4.配置team机制中broadcast
配置时只需将active backup改为对应模式就行