How to implement a network card in Linux to configure multiple IP addresses and load balancing of multiple network cards and

  
 

In the window we can implement multiple IP addresses for one network card and load balancing and redundancy with multiple network cards on the machine. Now let's talk about how to implement in LinuxOS

First, configure multiple ip addresses for a network card. We use the NIC eth0 as an example. We can use the ifconfig command to configure the NIC alias to implement a NIC configuration. Multiple ip addresses Ifconfig eth0:0 192.168.0.1Ifconfig eth0:1 192.168 .0.2Ifconfig eth0:2 192.168.0.3Ifconfig eth0:3 The result of 192.168.0.4 is as follows but we will find that the network card alias configured in acl mode will only take effect immediately, and will be invalid when the next time the network card is restarted or the Linux system is restarted. What can we do to make the configuration permanent? We can use the modified configuration file /etc/ifconfig/network-scripts/ifcfg-etho:x to permanently take effect: 1, cd /etc/ifconfig/network-scripts Use the cd command to switch to the network-scripts directory 2, Mkdir ifcfg-eth0:0 ifcfg-eth0:1 ifcfg-eth0:2 ifcfg-eth0:33, vim ifcfg-eth0:0 Open the ifcfg-eth0:0 file with vim and write the following DEVICE=eth0:0BOOTPROTO=staticONBOOT=yesIPADDR =192.168.0.1NETMASK=255.255.255.0HWADDR=00:0c:29:18:6e:35 Save and exit Create ifcfg-eth0:1, ifcfg-eth0:2, ifcfg-eth0:3 file as above to restart the network card Ifdown eth0Ifup Eth0 two, use BOND to achieve network card load balancing and redundancy. In order to keep the network unblocked in network services, it is sometimes necessary to use multiple network cards to achieve network load balancing and redundancy. In Linux, we use the bond module to implement the network card to eth0. And eth1 as an example First we need to load the bond module Vim /etc/modprobe.conf Open /etc/modprobe.conf Enter alias bond0 bonging in the file and load the bonding module Modprobe bonding2, modify /etc/sysconfig/network-scripts/ifcfg- Eth0 ifcfg-eth1DEVICE= eth0MASTER=bond0SLAVE=yesONBOOT=yesBOOTPROTO=none3, create /etc/sysconfig/network-scripts/ifcfg-bond0Device=bond0Bootproto=noneIpaddr=Natmask=Gateway=Onboot=Bonding_opyion=“mode=1 miion=50 primary=eth0” where mode =0 indicates that the implementation of redundancy primary=eth0 indicates that the default NIC is eth0Mode=1 to implement load balancing and restart the network service ifdown bond0Ifup bond0

Copyright © Windows knowledge All Rights Reserved