Home >Operation and Maintenance >Linux Operation and Maintenance >How to add IP address to Linux cloud server
Before adding IP, we need to prepare the following information. Please pay attention to replacing the corresponding parameters in angle brackets.
Existing IP address
1. Set a static IP.CentOS 6
vi /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=static ... IPADDR=<currentip> NETMASK=<netmask> GATEWAY=<gateway> DNS1=<dns1>2. Create a network interface configuration file.
vi /etc/sysconfig/network-scripts/ifcfg-eth0:1The content is as follows:
DEVICE=eth0:1 BOOTPROTO=static IPADDR=<newip> NETMASK=<netmask> ONBOOT=yes3. Activate the network interface and the IP address is added.
ifup eth0:1Ubuntu1. Check the network device name, such as eth0.
ip link show
vi /etc/network/interfacesThe 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:0Ubuntu 16.x1. Check the network device name, such as ens3.
ip link show
vi /etc/network/interfacesThe 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:0FreeBSD 101. Edit the network interface configuration file.
vi /etc/rc.conf
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!