To add an additional IP address to the VPS, you need to connect to the server using SSH or VNC, edit the network interface configuration file and restart the network service. Different distributions perform these operations differently.
/etc/sysconfig/network-scripts
:cd /etc/sysconfig/network-scripts/
ifcfg-eth0
under the name ifcfg-eth0:0
:cp ifcfg-eth0 ifcfg-eth0:0
vi ifcfg-eth0:0
# IPv6
and those that follow it - they all contain IPv6 at the beginning).DEVICE
by adding at the end :0
:DEVICE=eth0:0
IPADDR
by specifying your new IP:IPADDR=185.25.111.111
service network restart
After completing all the actions on the command ifconfig
you will see that you have an additional interface: eth:0
.
/etc/network/interfaces
:nano /etc/network/interfaces
eth0 inet
, before the IPv6 address settings (eth0 inet6
), add the following lines:up ip addr add 185.25.111.111/22 dev eth0 down ip addr add 185.25.111.111/22 dev eth0
Instead 185.25.111.111
you need to specify your new IP, and instead of 22
- the correct netmask.
ifdown eth0 && ifup eth0
ifdown --force eth0; ifup --force eth0
You can check the correctness of adding the address with the command ip addr
... You should display lines like this:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link / ether 10: 36: 3f: 04: 27: 47 brd ff: ff: ff: ff: ff: ff inet <old_IP> / 22 brd 185.25.111.255 scope global eth0 inet <new_IP>/22 scope global secondary eth0
/etc/network/interfaces
... In subsequent versions, the settings are made in "Netplan».
If you are using a non-root user, then at the beginning of most commands you may need to specify sudo
and after entering the password.
/etc/network/interfaces
:nano /etc/network/interfaces
auto eth0:0 iface eth0:0 inet static address 185.25.111.111 netmask 255.255.252.0
Instead 185.25.111.111
enter your new IP instead of 255.255.252.0
- the network mask that you have specified above.
/etc/init.d/networking restart
You can check the correctness of adding the address with the command ifconfig
... You should have an interface eth0:0
.
To configure interfaces in Netplan you need to do the following:
netplan generate
To check for existing files, you need to run:
ls -l /etc/netplan/
If the output contains total 0
, then file generation is required.
ifconfig -a
nano /etc/netplan/XXXXX.yaml
Important! Instead XXXXX
you need to specify the correct name of the existing file.
ethernet
specify the following lines:eth1: dhcp4: no dhcp6: no addresses: [XXX.XXX.XXX.XXX/YY, XXX.XXX.XXX.XXX/YY] gateway4: XXX.XXX.XXX.XXX nameservers: addresses: [XXX.XXX.XXX.XXX, XXX.XXX.XXX.XXX]
This instruction will change the interface settings:
eth1
- interface name. You need to specify the interface that you plan to configure.dhcp4
and dhcp6
- DHCP settings for IPv4 and IPv6. Need to indicate no
, since the IP will be set manually.addresses
- a sequence of IP addresses. Instead XXX.XXX.XXX.XXX
you should specify the required IP, instead of YY
- the desired mask. '2a05:410:0:9b5b::3/64'
».gateway4
- specifying the default gateway for IPv4. Instead XXX.XXX.XXX.XXX
you need to specify a standard gateway.nameservers
- nameserver settings.addresses
- sequence of IP addresses (indication in the block nameservers
parameter addresses
indicates the IP addresses of nameservers).netplan apply
You can check the correctness of adding the address with the command ifconfig
... You should have an interface eth1
.
/etc/conf.d/net
:nano /etc/conf.d/net
config_eth0="<old_IP> / 22 <new_IP>/22
Ctrl-X
, and then y
to confirm writing the file, and Enter
./etc/init.d/net.eth0 restart
You can check the correctness of adding the address with the command ifconfig
... You should have an interface eth0:1
.
/etc/sysconfig/network/ifcfg-eth0
:vim /etc/sysconfig/network/ifcfg-eth0
i
to enter edit mode.IPADDR_2='185.25.111.111' NETMASK_2='255.255.252.0'
Instead 185.25.111.111
you need to enter your new IP. Instead 255.255.252.0
- you need to specify the value that you have indicated above in the line NETMASK
.
service network restart
You can check the correctness of adding the address using service network status
... You should have lines like this:
network[13632]: eth0 IP address: <old_IP> network[13632]: secondary eth0 IP address: <new_IP> network[13632]: eth0 IP address: <IPv6> network[13632]: eth0 is up
/etc/sysconfig/network/ifcfg-eth0
:vi /etc/sysconfig/network/ifcfg-eth0
i
to enter edit mode.GATEWAY
add the following lines:IPADDR0=185.25.111.111 NETMASK0=255.255.252.0
Instead 185.25.111.111
you need to enter your new IP. Instead 255.255.252.0
- you need to specify the value that you have indicated above in the line NETMASK.
service network restart
You can check the correctness of adding the address with the command ip addr
... You should display lines like this:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link / ether 10: 36: 3f: 04: 27: 47 brd ff: ff: ff: ff: ff: ff inet <old_IP> / 22 brd 185.25.111.255 scope global eth0 inet <new_IP>/22 scope global secondary eth0