nmcli
1.聚合链路
1)nmcli 2)nmtui 3)teamd
2.grub:
1)修改centos7启动的等待时间 2)设置密码安全限制grub启动参数的修改 3)破解centos7的root账户口令 密码修改成功
4)centos7急救模式故障排除
添加网卡
Host only
网卡信息
[root@localhost Desktop]# ifconfig
eno16777736: flags=4163 mtu 1500
ether 00:0c:29:3c:01:c0 txqueuelen 1000 (Ethernet)
RX packets 118 bytes 7934 (7.7 KiB)
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
eno33554944: flags=4163 mtu 1500
inet 192.168.52.150 netmask 255.255.255.0 broadcast 192.168.52.255
inet6 fe80::20c:29ff:fe3c:1ca prefixlen 64 scopeid 0x20
ether 00:0c:29:3c:01:ca txqueuelen 1000 (Ethernet)
RX packets 121 bytes 8114 (7.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 21 bytes 4132 (4.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 0 (Local Loopback)
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
virbr0: flags=4099 mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 00:00:00:00:00:00 txqueuelen 0 (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
[root@localhost Desktop]#
添加master
[root@localhost Desktop]# nmcli connection add type team con-name team0 ifname team0 config '{"runner": {"name" :"activebackup"}}'
Connection 'team0' (38a63da2-abe8-4d9d-b2dc-53f9af9bd47a) successfully added.
添加slave
[root@localhost Desktop]# nmcli connection add type team-slave con-name team01 ifname eno16777736 master team0
Connection 'team01' (3538da6f-b985-4001-b07b-d6b26dfedfa1) successfully added.
[root@localhost Desktop]# nmcli connection add type team-slave con-name team02 ifname eno33554944 master team0
Connection 'team02' (c715e960-bfac-426a-83d3-72c2f8da6285) successfully added.
查看
[root@localhost Desktop]# nmcli connection show
NAME UUID TYPE DEVICE
Wired connection 2 7f080f4c-c3e7-484f-be42-fc248c8e5909 802-3-ethernet --
Wired connection 1 d5211d6d-2348-4cf7-ab0e-8a5e5492630c 802-3-ethernet eno33554944
eno16777736 ed486609-f625-4ac9-bd81-2768492fdb53 802-3-ethernet --
team02 c715e960-bfac-426a-83d3-72c2f8da6285 802-3-ethernet --
team01 3538da6f-b985-4001-b07b-d6b26dfedfa1 802-3-ethernet eno16777736
team0 38a63da2-abe8-4d9d-b2dc-53f9af9bd47a team team0
virbr0 b23c485d-8dda-47d6-93f4-4fcb0c690387 bridge virbr0
从查看到的信息中知道team02没有启动
启动team02
[root@localhost Desktop]# nmcli connection up team02
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5)
配置好team后,再查看网卡信息
[root@localhost Desktop]# ifconfig
eno16777736: flags=4163 mtu 1500
ether 00:0c:29:3c:01:c0 txqueuelen 1000 (Ethernet)
RX packets 217 bytes 14440 (14.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 27 bytes 4461 (4.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno33554944: flags=4163 mtu 1500
ether 00:0c:29:3c:01:c0 txqueuelen 1000 (Ethernet)
RX packets 233 bytes 17533 (17.1 KiB)
RX errors 0 dropped 6 overruns 0 frame 0
TX packets 22 bytes 4192 (4.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 0 (Local Loopback)
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
team0: flags=4163 mtu 1500
inet 192.168.52.147 netmask 255.255.255.0 broadcast 192.168.52.255
inet6 fe80::20c:29ff:fe3c:1c0 prefixlen 64 scopeid 0x20
ether 00:0c:29:3c:01:c0 txqueuelen 0 (Ethernet)
RX packets 27 bytes 1808 (1.7 KiB)
RX errors 0 dropped 6 overruns 0 frame 0
TX packets 27 bytes 4401 (4.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099 mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 00:00:00:00:00:00 txqueuelen 0 (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
从上面可以看出来eno16777736和eno33554944的mac是一样的
使用teamdctl查看team0
[root@localhost Desktop]# teamdctl team0 state
setup:
runner: activebackup
ports:
eno16777736
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
eno33554944
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: eno16777736
从这里可以知道为当前活动的是eno16777736,而eno16777736的mac地址是00:0c:29:3c:01:c0
停止team01来测试热备的效果
[root@localhost Desktop]# nmcli connection down team01
Connection 'team01' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
[root@localhost Desktop]# teamdctl team0 state
setup:
runner: activebackup
ports:
eno33554944
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: eno33554944
从上面可以看出来当前处于激活状态的网卡是eno33554944
再次启用
[root@localhost Desktop]# nmcli connection up team01
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
[root@localhost Desktop]# teamdctl team0 state
setup:
runner: activebackup
ports:
eno16777736
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
eno33554944
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: eno33554944
从这里可以看出来当前eno16777736被启用,但是是处于备用状态,当前处于热备状态
再次查看网卡等信息
[root@localhost Desktop]# ifconfig
eno16777736: flags=4163 mtu 1500
ether 00:0c:29:3c:01:c0 txqueuelen 1000 (Ethernet)
RX packets 242 bytes 16149 (15.7 KiB)
RX errors 0 dropped 4 overruns 0 frame 0
TX packets 27 bytes 4461 (4.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno33554944: flags=4163 mtu 1500
ether 00:0c:29:3c:01:c0 txqueuelen 1000 (Ethernet)
RX packets 253 bytes 18916 (18.4 KiB)
RX errors 0 dropped 25 overruns 0 frame 0
TX packets 34 bytes 5016 (4.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 0 (Local Loopback)
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
team0: flags=4163 mtu 1500
inet 192.168.52.147 netmask 255.255.255.0 broadcast 192.168.52.255
inet6 fe80::20c:29ff:fe3c:1c0 prefixlen 64 scopeid 0x20
ether 00:0c:29:3c:01:c0 txqueuelen 0 (Ethernet)
RX packets 47 bytes 2911 (2.8 KiB)
RX errors 0 dropped 29 overruns 0 frame 0
TX packets 39 bytes 5129 (5.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099 mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 00:00:00:00:00:00 txqueuelen 0 (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
mac地址依然是原来的
配置ip地址
[root@localhost Desktop]# nmcli connection modify team0 ipv4.addresses '192.168.10.30/24'
将IP地址的配置设置为手动
[root@localhost Desktop]# nmcli connection modify team0 ipv4.method manual
重启网络
[root@localhost Desktop]# systemctl restart network
再次查看
[root@localhost Desktop]# ifconfig
eno16777736: flags=4163 mtu 1500
ether 00:0c:29:3c:01:c0 txqueuelen 1000 (Ethernet)
RX packets 273 bytes 18291 (17.8 KiB)
RX errors 0 dropped 23 overruns 0 frame 0
TX packets 55 bytes 8141 (7.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno33554944: flags=4163 mtu 1500
ether 00:0c:29:3c:01:c0 txqueuelen 1000 (Ethernet)
RX packets 284 bytes 21110 (20.6 KiB)
RX errors 0 dropped 34 overruns 0 frame 0
TX packets 40 bytes 5807 (5.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 0 (Local Loopback)
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
team0: flags=4163 mtu 1500
inet 192.168.10.30 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::20c:29ff:fe3c:1c0 prefixlen 64 scopeid 0x20
ether 00:0c:29:3c:01:c0 txqueuelen 0 (Ethernet)
RX packets 10 bytes 460 (460.0 B)
RX errors 0 dropped 9 overruns 0 frame 0
TX packets 28 bytes 3584 (3.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099 mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 00:00:00:00:00:00 txqueuelen 0 (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
可以看到team0的IP地址已经变成192.168.10.30
ping 测试
[root@localhost Desktop]# ping 192.168.10.20
PING 192.168.10.20 (192.168.10.20) 56(84) bytes of data.
64 bytes from 192.168.10.20: icmp_seq=1 ttl=64 time=2.04 ms
64 bytes from 192.168.10.20: icmp_seq=2 ttl=64 time=0.321 ms
^C
--- 192.168.10.20 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.321/1.183/2.046/0.863 ms
[root@localhost Desktop]#
测试成功