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

How to add IP address to Linux cloud server

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-05-16 19:37:10
forward
1547 people have browsed it

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
Copy after login

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>
Copy after login
2. Create a network interface configuration file.

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

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

ifup eth0:1
Copy after login
Ubuntu

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

ip link show
Copy after login
Copy after login

2. Edit the network interface configuration file.

vi /etc/network/interfaces
Copy after login
Copy after login
The content is as follows:

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

ifup eth0:0
Copy after login
Ubuntu 16.x

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

ip link show
Copy after login
Copy after login

2. Edit the network interface configuration file.

vi /etc/network/interfaces
Copy after login
Copy after login
The content is as follows:

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

ifup ens3:0
Copy after login
FreeBSD 10

1. Edit the network interface configuration file.

vi /etc/rc.conf
Copy after login

The content is as follows:

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

/etc/rc.d/netif restart && /etc/rc.d/routing restart
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template