For some Linux VPS hosts, after we have multiple IP addresses or purchase the second IPV4 address, we directly resolve the IP addresses when using them, for example, if you want to use an IP address that corresponds to a domain name, do not set the configuration file on the server. However, some VPS must be set after a new IPV4 address is added.
In this article, the old Left will record that when a new IPV4 address is added to the company's machine today, it does not directly parse by default, but requires configuration files, record the process and configure it based on the CentOS6/Ubuntu 12.04 Environment Systems. If you need it later, you can copy it and use it. After all, it is difficult to use it when you are older.
1. Preparations before adding a new IPV4 address
1. For example, we originally had a primary IP address: 1.2.3.4
2. A new IP address is added: 1.2.3.8.
After purchasing a new IP address, restart the server.
2. IP adding process for CentOS 6 system
1. Configure the ifcfg-eth0 file
The code is as follows: |
Copy code |
/Etc/sysconfig/network-scripts/ifcfg-eth0
|
Use vi to open the configuration file:
Then, change BOOTPROTO = dhcp to BOOTPROTO = static, and then add the file
The code is as follows: |
Copy code |
IPADDR = [mainip]
NETMASK = [netmask]
GATEWAY = [gateway]
|
Add the above three lines at the end of the ifcfg-eth0, note that [] in the middle of the information about our primary IP address, mask, Gateway. Finally start
Ifup eth0.
2. Create and edit a ifcfg-eth0: 1 file
The code is as follows: |
Copy code |
/Etc/sysconfig/network-scripts/ifcfg-eth0: 1
|
We need to create a file management IP address for the second IP address.
The code is as follows: |
Copy code |
DEVICE = eth0: 1
BOOTPROTO = static
IPADDR = 1.2.3.8
ONBOOT = yes
|
Add the script to the file. Note that the second IP address must be changed to our own. Run
Ifup eth0: 1START takes effect. In this way, the configuration of adding the second IP address in the CentOS6 environment is complete.
Third, the process of adding an IP address to the Ubuntu 12.04 system
Edit the configuration of the/etc/network/interfaces file:
The code is as follows: |
Copy code |
Auto eth0: 0
Iface eth0: 0 inet static
Address 1.2.3.8
Netmask 255.255.255.0
|
Is it much simpler than CentOS? Directly add the above file script, pay attention to modifying the IP address, and finally execute
Ifup eth0: 0Effective.