Linux dual NIC binds to logical NIC

Source: Internet
Author: User

The network card bond is a kind of common technology in the production scene, which is bound by multi-net cards as a logical NIC, which realizes the redundancy, bandwidth expansion and load balance of the local network card.

The production environment server is: DELL

The NIC is: Fiber

Bond needs to modify the NIC configuration file involved

/etc/network-scripts/ifcfg-em1/etc/network-scripts/ifcfg-em2

  

New configuration file Required

/etc/network-scripts/ifcfg-bond0

  

To facilitate quick configuration, I put the configuration file on the USB flash drive (requires four files in the USB flash drive, the configuration of ifcfg-em1,ifcfg-em2,ifcfg-bond0, script cfg.sh), the script form of rapid configuration.

IFCFG-EM1 content is as follows

Device=em1name=em1hwaddr=80:18:44:ea:8b:b0type=ethernetonboot=yesmaster=bond0slave=yesnm_controlled= Nobootproto=noneuserctl=no

  

IFCFG-EM2 content is as follows

Device=em2name=em2hwaddr=80:18:44:ea:8b:b1type=ethernetonboot=yesnm_controlled=nobootproto=noneuserctl= Nomaster=bond0slave=yes

  

Ifcfg-bond0 content is as follows

Device=bond0type=bondname=bond0bootproto=noneonboot=yesipaddr=10.16.28.216prefix=24userctl=nobonding_master= yesipv4_failure_fatal=yesipv6init=nobonding_opts= "mode=4 miimon=100 downdelay=200 updelay=200 lacp_rate=1 Xmit_hash _policy=2 "bonding_slave_0=em1bonding_slave_1=em2nm_controlled=nogateway=10.16.28.4

  

cfg.sh script content is as follows

#脚本需要两个参数, this machine needs to configure the IP address, the native gateway address ip=$1gw=$2# to determine whether a given parameter, execute script without given parameters, script exits if [$IP = '-o $GW = ']thenecho ' IP or gateway wrong ' exitfi# the original NIC information on the backup device, my network card name is EM1 and em2cp/etc/sysconfig/network-scripts/ifcfg-em1/etc/sysconfig/network-scripts/ ifcfg-em1.bakcp/etc/sysconfig/network-scripts/ifcfg-em2/etc/sysconfig/network-scripts/ifcfg-em2.bak# Copy the prepared NIC configuration file to the specified directory cp/media/omsa71-cent/boot/ifcfg-*/etc/sysconfig/network-scripts/#将原网卡hwaddr信息恢复到配置文件cd/etc/ Sysconfig/network-scripts/sed-i s/' grep HWADDR ifcfg-em1 '/' grep HWADDR ifcfg-em1.bak '/ifcfg-em1sed-i s/' grep HWADDR if Cfg-em2 '/' grep HWADDR ifcfg-em2.bak '/ifcfg-em2# replace the IP address information in the configuration file to the native IP address sed-i s/10.16.28.216/$ip/ifcfg-bond0# Replace the gateway address information in the configuration file for the native gateway address sed-i s/10.16.28.4/$GW/ifcfg-bond0# View the changed configuration information grep 10.16.28 ifcfg-bond0# Modify the server startup mode to command line mode, Instead of graphical interface form sed-i s/id:5:/id:3://etc/inittabsleep aa off iptables and Selinuxservcie iptables stopchkconfig iptables--level 12345 offsetenforce 0sed-i s/selinux=enforcing/selinux=disabled//etc/selinux/config# Manually Restart the device for the configuration to take effect [inIt 6] 

  

Script Execution Example

#配置ip地址为10.16.28.200, configure the gateway address to 10.16.28.5sh-x cfg.sh 10.16.28.200 10.16.28.5

  

Linux dual NIC binds to logical NIC

Related Article

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.