Bind dual NICs in CentOS-bond0

Source: Internet
Author: User

Nic binding means that multiple NICs are logically used as one Nic. It can be divided into two types: Server Load balancer binding and redundant binding.

1. Edit the Virtual Network Interface Configuration File

[Root @ test ~] # More/etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE = bond0
IPADDR = 172.16.4.100
NETMASK = 255.255.255.0
BROADCAST = 172.16.4.255
NETWORK = 172.164.100
ONBOOT = yes

2. Edit the configuration files for each network card. Make sure that you back up the files before editing.

[Root @ test ~] # More/etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO = none
TYPE = Ethernet
DEVICE = eth0
ONBOOT = yes
MASTER = bond0
Slave = yes
[Root @ test ~] # More/etc/sysconfig/network-scripts/ifcfg-eth1
BOOTPROTO = none
TYPE = Ethernet
DEVICE = eth1
ONBOOT = yes
MASTER = bond0
Slave = yes




3. Modify the/etc/modprobe. conf file, back up the file, and add two lines.
Alias bond0 bonding
Options bond0 miimon = 100 mode = 1
Note:
(1) miimon indicates that the interval between link monitoring is millisecond, and miimon = 100 indicates that it checks whether the network card and the switch are connected every 100 milliseconds, if not, use another link.
(2) mode = 0 indicates the Server Load balancer mode. Both NICs work and must be supported by vswitches.
Mode = 1 indicates the redundancy mode. Only one network adapter works. If one problem occurs, another one is enabled.
Mode = 6 indicates the Server Load balancer mode. Both NICs work and do not require support from vswitches.

[Root @ test ~] # More/etc/modprobe. conf
Alias eth0 b44
Alias eth1 8139too
Alias usb-controller ehci-hcd
Alias usb-controller1 ohci-hcd
Alias bond0 bonding
Options bond0 miimon = 100 mode = 0

4. Add the following line to/etc/rc. d/rc. local:
Ifenslave bond0 eth0 eth1

[Root @ test ~] # More/etc/rc. d/rc. local
#! /Bin/sh
#
# This script will be executed * after * all the other init scripts.
# You can put your own initialization stuff in here if you don't
# Want to do the full Sys V style init stuff.

Touch/var/lock/subsys/local
Ifenslave bond0 eth0 eth1

5. After the restart, the Server Load balancer is working properly. service network restart, 6. Check bond0's working status.

[Root @ test ~] # More/proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v2.6.1 (October 29,200 4)

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
Link Failure Count: 1
Permanent HW addr: 00: 1b: b9: 58: 8b: b2

Slave Interface: eth1
MII Status: down
Link Failure Count: 0
Permanent HW addr: 00: 07: 40: 6c: ac: c8

7. view the working status of the bound Nic

[Root @ test ~] # Ifconfig-
Bond0 Link encap: Ethernet HWaddr00: 1B: B9: 58: 8B: B2

Inet addr: 172.16.4.100 Bcast: 172.16.4.255 Mask: 255.255.255.0
Inet6 addr: fe80: 200: ff: fe00: 0/64 Scope: Link
Up broadcast runningmaster multicast mtu: 1500 Metric: 1
RX packets: 744154 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 1866915 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 txqueuelen: 0
RX bytes: 1099876146 (1.0GiB) TX bytes: 121233595 (115.6 MiB)

Eth0 Link encap: Ethernet HWaddr00: 1B: B9: 58: 8B: B2
Inet6 addr: fe80: 21b: b9ff: fe58: 8bb2/64 Scope: Link
Up broadcast runningslave multicast mtu: 1500 Metric: 1
RX packets: 744154 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 1866905 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 FIG: 1000
RX bytes: 1099876146 (1.0GiB) TX bytes: 121232839 (115.6 MiB)
Interrupt: 9

Eth1 Link encap: Ethernet HWaddr00: 1B: B9: 58: 8B: B2
Inet6 addr: fe80: 21b: b9ff: fe58: 8bb2/64 Scope: Link
Up broadcast slavemulticast 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 FIG: 1000
RX bytes: 0 (0.0 B) TX bytes: 756 (756.0 B)
Interrupt: 11 Baseaddress: 0x1000

Lo Link encap: Local Loopback
Inetaddr: 127.0.0.1 Mask: 255.0.0.0
Inet6 addr: 1/128 Scope: Host
Up loopbackrunning mtu: 16436 Metric: 1
RX packets: 2129 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 2129 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 txqueuelen: 0
RX bytes: 1998893 (1.9MiB) TX bytes: 1998893 (1.9 MiB)

Sit0 Link encap: IPv6-in-IPv4
Noarp mtu: 1480 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: 0
RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 B)

Appendix:
DEVICE = physical DEVICE name
IPADDR = IP Address
NETMASK = mask Value
NETWORK = NETWORK address
BROADCAST = BROADCAST address
GATEWAY = GATEWAY address
ONBOOT = [yes | no] (whether to activate the device during boot)
USERCTL = [yes | no] (whether non-root users can control the device)
BOOTPROTO = [none | static | bootp | dhcp] (no protocol used during boot | static allocation | BOOTP protocol | DHCP protocol)
HWADDR = Your MAC address


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.