Add an ip alias in linux

Source: Internet
Author: User
Run the ifconfig command to view the IP address of the server. The example server has a physical network card device eth0 and local loopback device lo, the ip address of eth0

Use the standard network configuration tools ifconfig and route to add ip aliases.

Run the ifconfig command to view the IP address of the server. The example server has a physical network card device eth0 and local loopback device lo. the IP address of eth0 is 192.168.136.255, and the IP address of local loopback is 127.0.0.1.

Local loopback represents the local virtual interface of the device, so it is regarded as an interface that will never go down by default. It has two main functions:

First, test the network configuration of the local machine. if you can ping 127.0.0.1, the NIC and IP protocol of the local machine are installed successfully.

Second, some server/client applications must call resources on the server when running. Generally, you must specify the IP address of the server, however, when the program runs on the same machine without other servers, the server resources can be installed on the local machine, and the server IP address can be set to 127.0.0.1.

The following code uses the ifconfig and route commands to add aliases:

After adding the ip address, you can view the newly added ip address alias through ifconfig:

In this case, you can ping 192.168.136.132 on another server. in this case, ping through windows.

However, the ip alias configured only through the ifconfig and route commands disappears after the system is restarted. Therefore, we need to modify the file/etc/rc. local to enable the ifconfig and rohowever commands to run automatically when the system starts up.


Vi/etc/rc. local

Write in file

Ifconfig eth0: 1 192.168.136.132 broadcast 192.168.136.255 netmask 255.255.255.0 up
Route add-host 192.168.136.132 dev eth0: 1

Save.

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.