Techniques for setting up multiple network cards as virtual network cards under Linux

  

Many computers now have more than one network card, but one network card fails and the entire network is interrupted. But in Linux systems, as long as you create a Linux virtual network card, you will not encounter this kind of trouble. This article will introduce the skills of setting up multiple network cards into multiple virtual network cards under Linux.

to eth0 and eth1 to become virtual bond0 example: Prerequisites ------ binding: the same chipset model, but the card should have its own independent BIOS chips.

Setting Method

1. Create a virtual network interface configuration file ifcfg-bond0 and specify the network card 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 Modify 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, install module

Because the virtual network card is implemented in the kernel module, you need to install the module, in /etc/Add the following in modules.conf to enable the system to load the bonding module at startup. The external virtual network interface device is bond0.

Add the following two lines

alias bond0 bonding

options bond0 miimon=100 mode=0 --- 0 means that the two physical NICs are running in load balancing mode.

Note: miimon is used for link monitoring. For example: miimon=100, then the system monitors the link connection status every 100ms. If one line fails, it will transfer to another line; the mode value indicates the working mode. He has 0, 1, 2, 3 modes. The number is 0, 1 two.

mode=0 indicates that load balancing (round-robin) is the load balancing mode, and both network cards are in the active state.

mode=1 means that fault-tolerance (active-backup) provides redundancy, which means that by default only one NIC 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 in the active state and eth1 is in the standby state.

Bonding can only provide link monitoring, that is, whether the link from the host to the switch is connected. If only the external link of the switch is down, and the switch itself is not faulty, then bonding will continue to use the link without any problems.

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

cat /etc/rc.local

modprobe bonding miimon=100 mode=0

The configuration is complete and the host is rebooted.

Bringing up interface bond0 OK

Bringing up interface eth0 OK

Bringing up interface eth1 OK

The above is how many NICs are set up under Linux The skills of a virtual network card, so after the setup is complete, as long as a virtual network card can still be used, the virtual network card can work normally, it will not break the network.

Copyright © Windows knowledge All Rights Reserved