Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the tips for configuring linux network cards and binding dual network cards

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article to share with you is about linux network card configuration and dual network card binding tips is what, Xiaobian think quite practical, so share to everyone to learn, I hope you can read this article after harvest, not much to say, follow Xiaobian to see it.

RHEL6 linux network card configuration

standard file

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

DEVICE="eth0"

BOOTPROTO=static

NM_CONTROLLED="yes"

ONBOOT="yes"

TYPE="Ethernet"

UUID="e8d096fd-3e45-4303-8f7e-aa1808e03dba"

HWADDR=00:0C:29:D6:CE:89

IPADDR=192.168.10.119

PREFIX=24

GATEWAY=192.168.10.1

DEFROUTE=yes

IPV4_FAILURE_FATAL=yes

USERCTL=no

NAME="System eth0"

DNS1=8.8.8.8

DNS2=8.8.4.4

Note:

NM_CONTROLLED=yes means that NIC eth0 must be managed by NetworkManager, yes in this line| No switch control changes are immediate. Network Manager is actually a graphical network manager for managing network devices in the upper right corner of the screen. It is very convenient to assist you in managing wireless, ADSL, ××, etc., service NetworkManager start| stop determines whether you can see it in the upper right corner, and NM_CONTROLLED=yes in the main configuration file of eth0 NIC| The no entry determines whether your eth0 can be hosted by NNetwork Manager. When NM_CONTROLLED=yes, you want your NIC configuration to take effect. Restart NetworkManager service and then restart network service. At this time, your only advantage is that you can use NetworkManager to manage your NIC devices, such as eth0, ppp0, etc.; When NM_CONTROLLED=no, you want to make your network card configuration effective, do not restart NetworkManager service, directly restart the network service on the line, then your only disadvantage is that you can not use NetworkManager to manage your network card devices, such as eth0, ppp0, etc. In addition, when configuring kvm bridge mode, NM_CONTROLLED=yes in eth0 (actual NIC), NM_CONTROLLED=no in br0 (bridge NIC). After configuring the service network restart, use the ifconfig command to see if the associated interface is active.

USERCTL=no #Allow non-root users to control the device, set to no, can only be changed by root

ONBOOT="yes" #ONBOOT indicates whether the network card is activated when the system is started. Only the network card in the activated state can connect to the network for network communication. Yes means active, NO means inactive. RHEL6 above version default is NO.

RHEL6 and above dual NIC binding configuration

Prerequisites for binding: The chipset model of the NIC is the same, and the NIC should have its own independent BIOS chip.

1. Edit virtual network interface configuration file, specify network card IP

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

[root@redflag root]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 ifcfg-bond0

2 Configuration bond0

#vi ifcfg-bond0

Change the first line to DEVICE=bond0

# cat ifcfg-bond0

DEVICE=bond0

BOOTPROTO=static

IPADDR=172.31.3.13

NETMASK=255.255.255.0

BROADCAST=172.31.3.255

GATEWAY=172.31.3.254

ONBOOT=yes

TYPE=Ethernet

Be careful not to specify IP addresses, subnet masks, or NIC IDs for individual network cards. The above information can be specified in virtual bonding.

[root@redflag network-scripts]# cat ifcfg-eth0

DEVICE=eth0

USERCTL=no

BOOTPROTO=none

ONBOOT=yes

MASTER=bond0

SLAVE=yes

[root@redflag network-scripts]# cat ifcfg-eth2

DEVICE=eth2

USERCTL=no

BOOTPROTO=none

ONBOOT=yes

MASTER=bond0

SLAVE=yes

3 # vi /etc/modules.conf

Edit the/etc/modules.conf file and add the following line so that the system loads the bonding module at startup and the external virtual network interface device is bond0.

Add the following two lines

alias bond0 bonding

options bond0 miimon=100 mode=0

Description: miimon is used for link monitoring. For example:miimon=100, then the system monitors the link connection status every 100ms, and if one line is blocked, it will switch to another line; the value of mode indicates the working mode, which has four modes: 0, 1, 2, 3, and the commonly used ones are 0 and 1.

mode=0 means that load balancing (round-robin) is Load Balancer mode, and both NIC are working. Load Balancer mode of operation provides twice the bandwidth. In this case a piece of network card failure, only the server exit bandwidth drop, will not affect network usage.

mode=1 means fault-tolerance (active-backup) provides redundancy function, the working mode is the active and standby working mode, that is to say, only one NIC works by default, and the other one does backup. In the active/standby mode, when a network interface fails (such as the main switch power loss, etc.), there will be no network interruption, the system will work according to the order specified in/etc/rc.d/rc.local, the machine can still serve the outside, played a failure protection function.

Bonding can only provide link monitoring, that is, whether the link from the host to the switch is complete. If only the external link of the switch is down, and the switch itself is not faulty, then bonding will think that the link is fine and continue to use it.

4 # vi /etc/rc.d/rc.local

Add two lines

ifenslave bond0 eth0 eth2

route add -net 172.31.3.254 netmask 255.255.255.0 bond0

route add -net 192.168.228.0 netmask 255.255.255.0 gw 192.168.228.254 dev eth0

#service network restart

By this time the configuration has been completed and the machine restarted.

Restart will see the following message indicates that the configuration is successful

................

Bringing up interface bond0 OK

Bringing up interface eth0 OK

Bringing up interface eth2 OK

................

Network card bonding technology under Linux not only increases the reliability of the server, but also increases the available network bandwidth, providing users with uninterrupted key services.

The above is what linux network card configuration and dual network card binding tips are. Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report