Quickly set ip bond in Linux
In the early days of computer network popularization, many OS systems use a single Nic, that is, one Nic uses one IP address. With the increasing network requirements, we can bind and aggregate multiple NICs as a logical network interface to greatly improve the network throughput (I/O) of servers ), you can also set the binding mode based on different scenarios and requirements. This document briefly describes the configuration process.
1. Edit the ifcfg-bond0 File
### This article demonstrates the environment CentOS release 5.11, and bond eth0 and eth1
# Vi/etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE = bond0
BOOTPROTO = static
IPADDR = 192.168.9.33
NETMASK = 255.255.255.0
BROADCAST = 192.168.9.255
GATEWAY = 192.168.9.250
ONBOOT = yes
TYPE = Ethernet
2. Edit the eth0 and eth1 files
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0
### Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet
DEVICE = eth0
BOOTPROTO = none
HWADDR = xx: xx # the corresponding mac address is used here.
ONBOOT = yes
MASTER = bond0
SLAVE = yes
# Vi/etc/sysconfig/network-scripts/ifcfg-eth1
### Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet
DEVICE = eth1
BOOTPROTO = none
HWADDR = xx: xx
ONBOOT = yes
HOTPLUG = no
MASTER = bond0
SLAVE = yes
3. Edit The modprobe. conf file.
# Vi/etc/modprobe. conf
Add:
Alias bond0 bonding
Options bond0 miimon = 100 mode = 0
Note:
1). miimon = 100 is used to set the link monitoring interval. That is, the link status is monitored every Ms. Bonding only monitors links between hosts and switches. If there is a problem with the switch's outgoing link, bonding considers the link to be okay and continues to use it.
2). mode = 1 indicates redundancy. In addition, there are four modes: 0, 2, and 3. 0 indicates Load Balancing
3). For more details, refer to: in-depth analysis of seven modes of Dual-nic binding in Linux
4. Restart the network
# Service network restart
5. Verify
Ping the bound ip address from another machine. During the ping process, unplug the eth0 or eth1 network cable and check whether the network continues to work normally.
### Refer to the following verification results after bond is started
# Less/proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.4.0-2 (October 7, 2008)
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (MS): 100
Up Delay (MS): 0
Down Delay (MS): 0
Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 44: a8: 42: 0b: a7: a5
Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 44: a8: 42: 0b: a7: a6
### View the IP Address Configuration of the current host
# Ip addr
1: lo: <LOOPBACK, UP, LOWER_UP> mtu 16436 qdisc noqueue
Link/loopback 00: 00: 00: 00: 00: 00 brd 00: 00: 00: 00: 00: 00
Inet 127.0.0.1/8 scope host lo
Inet6: 1/128 scope host
Valid_lft forever preferred_lft forever
2: eth0: <BROADCAST, MULTICAST, SLAVE, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 qlen 1000
Link/ether 44: a8: 42: 0b: a7: a5 brd ff: ff
3: eth1: <BROADCAST, MULTICAST, SLAVE, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 qlen 1000
Link/ether 44: a8: 42: 0b: a7: a5 brd ff: ff
4: eth2: <BROADCAST, MULTICAST> mtu 1500 qdisc noop qlen 1000
Link/ether 44: a8: 42: 0b: a7: a7 brd ff: ff
5: eth3: <NO-CARRIER, BROADCAST, MULTICAST, UP> mtu 1500 qdisc pfifo_fast qlen 1000
Link/ether 44: a8: 42: 0b: a7: a8 brd ff: ff
Inet 192.168.10.15/24 brd 192.168.10.255 scope global eth3
6: sit0: <NOARP> mtu 1480 qdisc noop
Link/sit 0.0.0.0 brd 0.0.0.0
7: bond0: <BROADCAST, MULTICAST, MASTER, UP, LOWER_UP> mtu 1500 qdisc noqueue
Link/ether 44: a8: 42: 0b: a7: a5 brd ff: ff
Inet 192.168.9.33/24 brd 192.168.9.255 scope global bond0
Inet6 fe80: 46a8: 42ff: fe0b: a7a5/64 scope link
Valid_lft forever preferred_lft forever
This article permanently updates the link address: