2、关闭networkmanager
--关闭networkmanager服务.
[root@liujun ~]# systemctl disable --now NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
Removed symlink /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service.
说明:now表示立即关闭NetworkManager服务.
3、网卡配置文件
--修改网卡配置文件,注意网卡名需结合实际情况进行配置.
3.1、网卡原数据
[root@liujun ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
inet 192.168.133.218/24 brd 192.168.133.255 scope global noprefixroute dynamic ens33
valid_lft 1038sec preferred_lft 1038sec
inet6 fe80::e107:1ed3:d4e5:f7ab/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:98:c5:69 brd ff:ff:ff:ff:ff:ff
inet 192.168.133.120/24 brd 192.168.133.255 scope global noprefixroute ens37
valid_lft forever preferred_lft forever
inet6 fe80::e007:4abd:58d:5da3/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:98:c5:73 brd ff:ff:ff:ff:ff:ff
inet 192.168.133.217/24 brd 192.168.133.255 scope global noprefixroute dynamic ens38
valid_lft 1038sec preferred_lft 1038sec
inet6 fe80::46fe:1c1:a824:9da9/64 scope link noprefixroute
valid_lft forever preferred_lft forever
5: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:a8:7c:6f brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
6: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:a8:7c:6f brd ff:ff:ff:ff:ff:ff
[root@liujun network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@liujun network-scripts]# cat ifcfg-ens37
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens37
UUID=e7191296-fd65-478d-936e-f43dc98f1745
DEVICE=ens37
ONBOOT=yes
IPADDR=192.168.133.120
DNS1=192.168.133.2
GATEWAY=192.168.133.2
PREFIX=24
3.2、修改配置文件
3.2.1、ifcfg-ens37
[root@liujun network-scripts]# vi ifcfg-ens37
按如下修改:
DEVICE=ens37
NAME=ens37
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
[root@liujun network-scripts]# cp ifcfg-ens37 ifcfg-ens33
[root@liujun network-scripts]# cp ifcfg-ens37 ifcfg-ens38
3.2.2、ifcfg-ens33
[root@liujun network-scripts]# vi ifcfg-ens33
按如下修改:
DEVICE=ens33
NAME=ens33
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
3.2.3、ifcfg-ens38
[root@liujun network-scripts]# vi ifcfg-ens38
按如下修改:
DEVICE=ens38
NAME=ens38
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
3.3、配置bond0
[root@liujun network-scripts]# vi ifcfg-bond0
按如下修改
DEVICE=bond0
TYPE=bond0
BONDING_MASTER=yes
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.133.120
NETMASK=255.255.255.0
GATEWAY=192.168.133.2
BONDING_OPTS="mode=0 miimon=100"
BONDING_MASTER=yes
NM_CONTROLLED=no
--加载bond模块
[root@liujun network-scripts]# vi /etc/modprobe.d/bonding.conf
添加如下:
alias bond0 binding
options bond0 miimon=100 mode=0
--开启网卡混杂模式
[root@liujun ~]# chmod +x /etc/rc.local
[root@liujun ~]# vi /etc/rc.local
添加如下内容
ip link set ens33 promisc on
ip link set ens37 promisc on
ip link set ens38 promisc on
4、测试
4.1、移除1块网卡
--重启服务器后,移除其中1块网卡进行测试.
[root@liujun ~]# reboot
[root@liujun ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,PROMISC,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
3: ens37: <BROADCAST,MULTICAST,PROMISC,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
4: ens38: <BROADCAST,MULTICAST,PROMISC,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:0c:29:98:c5:5f brd ff:ff:ff:ff:ff:ff
inet 192.168.133.120/24 brd 192.168.133.255 scope global bond0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe98:c55f/64 scope link
valid_lft forever preferred_lft forever
6: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:a8:7c:6f brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
7: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:a8:7c:6f brd ff:ff:ff:ff:ff:ff
说明:如上显示三张网卡,现移除一块测试.