Set dual-physical Nic to virtual Nic in Linux

Source: Internet
Author: User

Set dual-physical Nic to virtual Nic in Linux

To provide high network availability, We need to bind multiple network cards to a virtual network card to provide external services. This can prevent a network card from being damaged or connection interruption caused by network connection failure.

Let's use eth0 and eth1 to virtualize bond0 as an example: ------ prerequisites for binding: the chipset model is the same, and the NIC should have its own independent BIOS chip.

Operating Platform: OLE Linux 6.6

1. Create a virtual network interface profile ifcfg-bond0 and specify the nic ip: vi/etc/sysconfig/network-scripts/ifcfg-bond0

Cat/etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE = bond0

BOOTPROTO = static

IPADDR = 10.0.11.10

NETMASK = 255.255.252.0

GATWAY = 10.0.11.1

ONBOOT = yes

USERCTL = no

TYPE = Ethernet

2, respectively modify the ifcfg-eth0 and ifcfg-eth1 ----- can not set information about IP, gateway, subnet mask and so on.

Cat/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE = eth0

BOOTPROTO = dhcp

ONBOOT = yes

USERCTL = no

MASTER = bond0

SLAVE = yes

TYPE = Ethernet

Cat/etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE = eth1

BOOTPROTO = dhcp

ONBOOT = yes

USERCTL = no

MASTER = bond0

SLAVE = yes

TYPE = Ethernet

3. Because the virtual Nic is actually implemented in the kernel module, a module must be installed in/etc/modules. add the following content in conf to enable the system to load the bonding module at startup, and the external virtual network interface device is bond0.

Add the following two rows
Alias bond0 bonding
Options bond0 miimon = 100 mode = 0 --- 0 indicates that the two physical NICs are run in load balancing mode.

Note: miimon is used for link monitoring. For example: miimon = 100, The system monitors the link connection status every Ms. If one line fails, it is transferred to another line. The value of mode indicates the working mode, which has a total, two or three modes, commonly used: 0, 1.

Mode = 0 indicates that the load balancing (round-robin) method is load balancing, and both NICs are active.

Mode = 1 indicates that fault-tolerance (active-backup) provides redundancy, that is, by default, only one network adapter is active and the other is backed up.

If this mode is used, options bond0 miimon = 100 mode = 1 primary = eth0 --- indicates that eth0 is active and eth1 is standby.

Bonding can only provide link monitoring, that is, whether the link from the host to the switch is connected. If the external link of the switch is down and the switch is not faulty, bonding considers that the link is correct and continues to be used.

4. Add the following command to/etc/rc. local.

Cat/etc/rc. local

Modprobe bonding miimon = 100 mode = 0

Host restart after configuration is complete.
Bringing up interface bond0 OK
Bringing up interface eth0 OK
Bringing up interface eth1 OK


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.