Bind multiple IP addresses to a single NIC in CentOS and share one IP address with multiple NICs

Source: Internet
Author: User
In centos, you sometimes need to bind multiple IP addresses to one network card. This article describes the Redhat series (redhat, FedoraCore, Centos) and a method that is widely used in other Linux systems such as Gentoo. 1. how to bind multiple IP addresses to a single Nic in the CentOS series. assume that the NIC to bind multiple IP addresses is eth0. create one in the/etc/sysconfig/network-scripts directory.

In centos, you sometimes need to bind multiple IP addresses to one network card. This article describes the Redhat series (redhat, Fedora Core, Centos) and a method that is widely used in other Linux systems such as Gentoo.

  1. how to bind multiple IP addresses to a single Nic in the CentOS series

Suppose the NIC that needs to bind multiple IP addresses is eth0, please create a file named ifcfg-eth0: 0 in the/etc/sysconfig/network-scripts directory,

Content example:

 

DEVICE = "eth0: 0 ″
IPADDR = "192.168.0.2 ″
BROADCAST = "172.160.255 ″
NETMASK = "255.255.255.0 ″
ONBOOT = "yes"

The DEVICE is the DEVICE name,

The IP address of the device,

BROADCAST is a BROADCAST address,

NETMASK is the subnet mask,

ONBOOT indicates automatic startup when the system starts.

If you need to bind another IP address,

You only need to add the file name and the eth0: x in the DEVICE in the file.

LINUX supports up to 255 IP aliases

2. it is widely used to bind multiple IP addresses to a single NIC.

 

Ifconfig eth0: 1 192.168.0.3 broadcast 192.168.0.255 netmask 255.255.255.0

You can add the preceding command to the self-running startup file. under Gentoo, it is/etc/conf. d/local. start, while some versions of Linux are/etc/rc. d/rc. local.

  3. how to share a single IP address with multiple NICs

You can use multiple NICs to create a network card with the same IP address. This technology actually exists in sun and cisco, respectively known as Trunking and etherchannel technology. in linux, this technology is called bonding. Because bonding is included in kernel 2.4.x, you only need to select Bonding driver support in network device options during compilation.

Then, recompile the core, restart the computer, and execute the following command:

 

Ismod bonding
Ifconfig eth0 down
Ifconfig eth1 down
Ifconfig bond0 ipaddress
Ifenslave bond0 eth0
Ifenslave bond0 eth1

Now the two NICs work like one, which can improve data transmission between cluster nodes.

You 'd better write these statements as a script, and then use/etc/rc. d/rc. local or/etc/conf. d/local. start is called to take effect on the server.

Bonding is a good choice for servers. when there is no Gigabit Nic, using two or three 100 m NICs as bonding can greatly increase the bandwidth between servers and switches. However, you need to set the two ports mapped to the same virtual interface on the vSwitch to connect to the bonding 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.