Configure multiple IP addresses for the next Nic in linux

Source: Internet
Author: User
Article title: configure multiple IP addresses for the next Nic in linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

If there is no graphical interface under linux, the configuration is really inconvenient. Recently, you have encountered a problem where you need to configure multiple IP addresses for a single NIC. In the text console, there are netconfig and ifconfig tools in the text console. netconfig is a little more convenient in graphical form, but there is no document, and you can still configure an ip address. However, if you configure multiple IP addresses, you may be confused, only ifconfig can be used

# Ifconfig eth0 192.168.0.1 netmask limit 255.0 up description: up indicates immediate activation

How can I configure multiple IP addresses for a single network adapter eth0? if the ifconfig command is used, only eth0 needs to be changed. change eth0 to eth0: x (x is 0-255, for example, eth0: 0 or eth0: 1). eth0: x is called a virtual network interface and is built on a network interface.

Therefore, you can use the following command to configure multiple ip addresses for a single NIC:

# Ifconfig eth0: 0 192.168.0.1 netmask 255.255.255.0 up

# Ifconfig eth0: 1 192.168.0.2 netmask 255.255.255.0 up

After the ping test is passed, the function of configuring multiple ip addresses for a single NIC is completed. In this way, the IP address will be changed back after reboot, so you need to set to automatically activate the IP address setting at startup. The methods are as follows:

First:

Add the above command ifconfig to rc. local.

Second:

Is modeled on/etc/sysconfig/network-scripts/ifcfg-eth0 add a file named according to the name of the network virtual interface, such as ifcfg-eth0: 0 or ifcfg-eth0: 1, etc.

Next look at the ifcfg-eth0: 0 file configuration information

DEVICE = eth0: 0 # network virtual interface eth0: 0

ONBOOT = yes # activated at startup

BOOTPROTO = static # use a static IP address

IPADDR = 192.168.0.1 # assign an IP address

NETMASK = 255.255.255.0 # subnet mask

Disable an ip address.

# Ifconfig eth0: 0 down

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.