Redhat Linux NIC Configuration and bindings

Source: Internet
Author: User
Tags bind

Redhat Linux Network configuration, basically by modifying several configuration files to achieve, although can also use Ifconfig to set IP, with route to configure the default gateway, with hostname to configure the hostname, but restart will be lost.

Related configuration Files

/ect/hosts 配置主机名和IP地址的对应
/etc/sysconfig/network 配置主机名和网关
/etc/sysconfig/network-scripts/ifcfg-eth0 eth0配置文件,eth1则文件名为ifcfg-eth1,以此类推

One, network card configuration

Let's say we want to configure the IP address 192.168.168.1/24 with host name Test,eth0, gateway address 192.168.168.250

The contents of the/etc/sysconfig/network file are as follows:

NETWORKING=yes
HOSTNAME=test
GATEWAY=192.168.168.250

Eth0 the corresponding configuration file/etc/sysconfig/network-scripts/ifcfg-eth0 the contents as follows:

DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.168.1
NETMASK=255.255.255.0
TYPE=Ethernet
ONBOOT=yes

Two, single card binding multiple IP

Sometimes we need to configure multiple IPs on a single network card, for example, in the above example, we also need to configure IP 192.168.168.2 and 192.168.168.3 for eth0. Then you will need to create two new profiles under/etc/sysconfig/network-scripts:

ifcfg-eth0:0 contents are as follows:

DEVICE=eth0:0
BOOTPROTO=static
IPADDR=192.168.168.2
NETMASK=255.255.255.0
ONBOOT=yes

Ifcfg-eth0:1 contents are as follows:

DEVICE=eth0:1
BOOTPROTO=static
IPADDR=192.168.168.3
NETMASK=255.255.255.0
ONBOOT=yes

Three, multiple network cards are bound into a virtual network card

In order to provide high availability of the network, we may need to bind multiple network cards into a single virtual NIC to provide services, so that even if one of the physical network card fails, it will not cause the connection to be interrupted. For example, we can bind eth0 and eth1 to a virtual NIC Bond0

First, create a virtual NIC bond0 configuration file ifcfg-bond0 under/etc/sysconfig/network-scripts/, as follows

DEVICE=bond0
BOOTPROTO=none
BROADCAST=192.168.168.255
IPADDR=192.168.168.1
NETMASK=255.255.255.0
NETWORK=192.168.168.0
ONBOOT=yes
TYPE=Ethernet
GATEWAY=192.168.168.250
USERCTL=no

Then modify the eth0 and eth1 configuration files separately

Ifcfg-eth0 content:

DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes

Ifcfg-eth1 Content

DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes

Because the Linux virtual network card is implemented in the kernel module, so it is necessary to install the module. Add the following in the/etc/modules.conf file (if there is no file, create a new one):

alias bond0 bonding
options bond0 miimon=100 mode=1 primary=eth0

Where miimon=100 means that the link connection status is checked once per 100ms, and if not, the physical network card is switched

Mode=1 represents the primary standby mode, which means that only one network adapter is active and provides only failure protection. If mode=0 is load-balanced, all network cards are active, and some other modes are rarely used

Primary=eth0 indicates that eth0 is the default active network card in the primary standby mode

Finally, add in the/etc/rc.local

modprobe bonding miimon=100 mode=1

Restart the machine can see the virtual network card has been in effect, you can plug the two physical network card to test the network cable, but the Linux network card takes over the time seems relatively long.

Author: Ningoo | "When reproduced, please be sure to hyperlink form to indicate the original source of the article and author information and this statement"

Address: http://www.ningoo.net/html/2007/redhat_linux_network_configuration_and_bond.html

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.