Centos6.5 multi-nic configuration redundancy (bond)

Source: Internet
Author: User

Centos6.5 multi-nic configuration redundancy (bond)

Why do we suddenly remember to configure this? When I went to the data center for implementation last time, I found that most servers have at least two NICs inserted with network cables to connect to switches, but they may have only one ip address, the redundant Nic must be redundant or load balancing. In the following experiment, we will mainly use vmware

Step 1: Prepare the experiment environment

OS: centos6.5
NIC: Dual NIC (we can just add a NIC with vmware. For example, the added Nic must be in the same network segment)

Step 2: Modify the NIC configuration file

// I Already Have eth0 (192.168.40.10). The newly added eth1 is now designed to set eth0 and eth1 to slave mode. Their master Nic bond0 must be assigned to the ip Address: 192.168.40.10, a bit like a proxy Nic.

[Root @ web1 ~] # Ifconfig-a # view all added Nic information, whether or not eth0 Link encap: Ethernet HWaddr 00: 0C: 29: 48: 7C: E8 inet addr: 192.168.40.10 Bcast: 192.168.40.255 Mask: 255.255.255.0 inet6 addr: fe80: 20c: 29ff: fe48: 7ce8/64 Scope: Link up broadcast running multicast mtu: 1500 Metric: 1 RX packets: 0 errors: 0 dropped: 0 overruns: 0 frame: 0 TX packets: 10 errors: 0 dropped: 0 overruns: 0 carrier: 0 collisions: 0 txqueuelen: 1000 RX bytes: 0 (0.0 B) TX bytes: 636 (636.0 B) Interrupt: 19 Base address: 0x2024 eth1 Link encap: Ethernet HWaddr 00: 0C: 29: 48: 7C: F2 BROADCAST MULTICAST MTU: 1500 Metric: 1 RX packets: 0 errors: 0 dropped: 0 overruns: 0 frame: 0 TX packets: 0 errors: 0 dropped: 0 overruns: 0 carrier: 0 collisions: 0 txqueuelen: 1000 RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 B) Interrupt: 16 Base address: 0x20a4 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: 16436 Metric: 1 RX packets: 108 errors: 0 dropped: 0 overruns: 0 frame: 0 TX packets: 108 errors: 0 dropped: 0 overruns: 0 carrier: 0 collisions: 0 txqueuelen: 0 RX bytes: 7296 (7.1 KiB) TX bytes: 7296 (7.1 KiB)

// Modify the NIC configuration file as follows

[Root @ web1 network-scripts] # cd/etc/sysconfig/network-scripts/# Switch to the directory of the NIC configuration file [root @ web1 network-scripts] # cat ifcfg-eth0 # entity you do not need to configure an IP address for the NIC, DEVICE = eth0TYPE = EthernetONBOOT = yesBOOTPROTO = noneMASTER = bond0 # specify your master Nic SLAVE = yes # enable the slave mode [root @ web1 network-scripts] # cat ifcfg-eth1DEVICE = eth1TYPE = EthernetONBOOT = yesBOOTPROTO = noneMASTER = bond0SLAVE = yes [root @ web1 network-scripts] # cat ifcfg-bond0 DEVICE = bond0TYPE = EthernetONBOOT = yesBOOTPROTO = noneIPADDR = 192.168.40.10NETMASK = 255.255.255.0
Step 3: modify the system bonding support file
[Root @ web1 network-scripts] # vim/etc/modprobe. d/bonding. conf # Add the following two lines. miimon specifies how many ms to check the NIC status. alias bond0 bondingoptions bond0 miimon = 120 mode = 1

// A total of 7 modes, 6, detailed can refer to the http://support.huawei.com/ecommunity/bbs/10155553.html

Mode = 0: Load Balancing mode, with automatic backup, but requires "Switch" support and settings. Mode = 1: automatic backup mode. If one line is disconnected, other lines are automatically backed up. # Common mode = 6: Load Balancing mode, with automatic backup, without "Switch" support and setting. # Common

Step 4: restart the NIC
[Root @ web1 network-scripts] #/etc/init. d/network restart # restart the service. I didn't enable NetworkManager, so I only need to restart the network and can close the interface eth0:/etc/sysconfig/network-scripts/ifdown-eth: line 116:/sys/class/net/bond0/bonding/slaves: the file or directory does not exist. [OK] disable the loopback interface: [OK] The loopback interface is displayed: [OK] bond0: Determining if ip address 192.168.40.10 is already in use for device bond0... [OK] # Here we have succeeded [root @ web1 network-scripts] # ip a # querying whether the bond0 ip Address has taken effect 1: lo: <LOOPBACK, UP, LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00: 00: 00: 00: 00: 00 brd 00: 00: 00: 00: 00 inet 127.0.0.1/8 scope host lo inet6: 1/128 scope host valid_lft forever preferred_lft forever2: eth0: <BROADCAST, MULTICAST, SLAVE, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UNKNOWN qlen 1000 link/ether 00: 0c: 29: 48: 7c: e8 brd ff: ff3: eth1: <BROADCAST, MULTICAST, SLAVE, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UNKNOWN qlen 1000 link/ether 00: 0c: 29: 48: 7c: e8 brd ff: ff: ff4: bond0: <BROADCAST, MULTICAST, MASTER, UP, LOWER_UP> mtu 1500 qdisc noqueue state UP link/ether 00: 0c: 29: 48: 7c: e8 brd ff: ff inet 192.168.40.10/24 brd 192.168.40.255 scope global bond0 inet6 fe80: 20c: 29ff: fe48: 7ce8/64 scope link tentative dadfailed valid_lft forever preferred_lft forever [root @ web1 network-scripts] # netstat-I # view Nic traffic Kernel Interface tableIface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flgbond0 1500 0 43 0 0 0 17 0 0 BMmRUeth0 1500 0 32 0 0 0 0 0 0 0 0 BMsRUeth1 1500 0 11 0 0 0 0 0 0 0 0 BMsRUlo 16436 0 148 0 0 0 0 148 0 0 0 LRU // success

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.