Network card binding bond under Linux

View network card information

[root@test ~]# nmcli dev
DEVICE     TYPE              STATE       
eth0       802-3-ethernet    connected   
eth1       802-3-ethernet    connected   -- IP 192.168.2.100
eth2       802-3-ethernet    connecting (getting IP configuration)

Purpose: Network card eth1 eth2 in use. Bind eth1 the2 as bond0

Shut down the NetworkManager service

[root@test network-scripts]# chkconfig --list | grep NetworkManager
NetworkManager 	0:off	1:off	2:on	3:on	4:on	5:on	6:off
[root@test network-scripts]# service NetworkManager stop
Stopping NetworkManager daemon:                            [  OK  ]
[root@test network-scripts]# chkconfig NetworkManager off
[root@test network-scripts]# chkconfig --list | grep NetworkManager
NetworkManager 	0:off	1:off	2:off	3:off	4:off	5:off	6:off
[root@test network-scripts]#

Go to the /etc/modprobe.d directory. Create a bonded device 

echo "alias bond0 bonding" > /etc/modprobe.d/bonding.conf

Backup the original NIC configuration file, backup ifcfg-eth0, ifcfg-eth1. Create the ifcfg-bond0 file. and edit the ifcfg-eth0 ifcfg-eth1 file

[root@test network-scripts]# cp ifcfg-eth0 ifcfg-eth0_bak20180423
[root@test network-scripts]# cp ifcfg-eth1 ifcfg-eth1_bak20180423
[root@test network-scripts]# cp ifcfg-eth2 ifcfg-eth2_bak20180423

Contents of the ifcfg-bond0 file

# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE="bond0"
BONDING_OPTS="mode=1 miimon=100 primary=eth1"
NM_CONTROLLED="no"
IPADDR="192.168.2.100"
NETMASK="255.255.255.0"
GATEWAY="192.168.2.1"
ONBOOT="yes"

Contents of the ifcfg-eth1 file

[root@test network-scripts]# cat ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
UUID=0578ea57-3027-43f3-a070-e3bd523e2810
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPV6INIT=no
HWADDR=08:00:27:3D:6D:C4
SLAVE=yes
MASTER=bond0
[root@test network-scripts]#

Contents of the ifcfg-eth2 file

[root@test network-scripts]# cat ifcfg-eth2
DEVICE=eth2
TYPE=Ethernet
UUID=291cc332-f718-4e56-9986-4fcbf5c7f66b
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
HWADDR = 08: 00: 27: 6A: 01: 30
IPV6INIT=no
SLAVE=yes
MASTER=bond0
[root@test network-scripts]#

restart network service

[root@test network-scripts]# service network restart
Shutting down interface bond0:                             [  OK  ]
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface bond0:  Determining if ip address 192.168.2.100 is already in use for device bond0...
                                                           [  OK  ]
Bringing up interface eth0:  
Determining IP information for eth0... done.
                                                           [  OK  ]
[root@test network-scripts]#

View IP address

[root@test network-scripts]# ifconfig
bond0     Link encap:Ethernet  HWaddr 08:00:27:3D:6D:C4  
          inet addr:192.168.2.100  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe3d:6dc4/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:448 errors:0 dropped:29 overruns:0 frame:0
          TX packets:348 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:38157 (37.2 KiB)  TX bytes:44557 (43.5 KiB)

eth0      Link encap:Ethernet  HWaddr 08:00:27:6E:6D:78  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe6e:6d78/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:248 errors:0 dropped:0 overruns:0 frame:0
          TX packets:417 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:27391 (26.7 KiB)  TX bytes:37846 (36.9 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:3D:6D:C4  
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:2723 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1854 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:245368 (239.6 KiB)  TX bytes:232118 (226.6 KiB)

eth2      Link encap:Ethernet  HWaddr 08:00:27:3D:6D:C4  
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:129 errors:0 dropped:29 overruns:0 frame:0
          TX packets:114 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:9081 (8.8 KiB)  TX bytes:26200 (25.5 KiB)

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:86 errors:0 dropped:0 overruns:0 frame:0
          TX packets:86 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:8328 (8.1 KiB)  TX bytes:8328 (8.1 KiB)

[root@test network-scripts]#

View Mac address 

[root@test ~]# ifconfig | grep HWaddr
bond0     Link encap:Ethernet  HWaddr 08:00:27:3D:6D:C4  
eth0      Link encap:Ethernet  HWaddr 08:00:27:6E:6D:78  
eth1      Link encap:Ethernet  HWaddr 08:00:27:3D:6D:C4  
eth2      Link encap:Ethernet  HWaddr 08:00:27:3D:6D:C4  
[root@test ~]#

END

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324733113&siteId=291194637