Home  >  Article  >  Operation and Maintenance  >  How to add IP address to Linux cloud server

How to add IP address to Linux cloud server

WBOY
WBOYforward
2023-05-16 19:37:101420browse

Before adding IP, we need to prepare the following information. Please pay attention to replacing the corresponding parameters in angle brackets.

  • Existing IP address , subnet mask , default gateway

  • ##New IP address, subnet mask

  • ##DNS server
  • ##In order to use For the new IP to take effect, you need to perform a restart operation in the cloud server management in the management center. You can use the ping command to check whether the addition is successful.

CentOS 6

1. Set a static IP.

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Change BOOTPROTO=dhcp to BOOTPROTO=static, and add the IP address, subnet mask and default gateway at the end of the file. This information can be obtained in the cloud server management.

BOOTPROTO=static
...
IPADDR=<currentip>
NETMASK=<netmask>
GATEWAY=<gateway>
DNS1=<dns1>
2. Create a network interface configuration file.

vi /etc/sysconfig/network-scripts/ifcfg-eth0:1
The content is as follows:

DEVICE=eth0:1
BOOTPROTO=static
IPADDR=<newip>
NETMASK=<netmask>
ONBOOT=yes
3. Activate the network interface and the IP address is added.

ifup eth0:1
Ubuntu

1. Check the network device name, such as eth0.

ip link show

2. Edit the network interface configuration file.

vi /etc/network/interfaces
The content is as follows:

auto eth0:0
iface eth0:0 inet static
address <newip>
netmask <netmask>
3. Activate the network interface and the IP address is added.

ifup eth0:0
Ubuntu 16.x

1. Check the network device name, such as ens3.

ip link show

2. Edit the network interface configuration file.

vi /etc/network/interfaces
The content is as follows:

auto ens3:0
iface ens3:0 inet static
address <newip>
netmask <netmask>
3. Activate the network interface and the IP address is added.

ifup ens3:0
FreeBSD 10

1. Edit the network interface configuration file.

vi /etc/rc.conf

The content is as follows:

ifconfig_vtnet0_alias0="<newip> netmask <netmask>"
2. Execute the following command to restart the network.

/etc/rc.d/netif restart && /etc/rc.d/routing restart

The above is the detailed content of How to add IP address to Linux cloud server. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete