Create and update firewall rules; manage SSH access info and IP addresses for the instances in your IDrive® Compute account.
Add IPv4 Address to Your Instance
The Internet Protocol Version 4 (IPv4) is the widely-used version and this address system is used to identify interfaces and locate hosts on the network. You can add an IPv4 address to your instance and thereby login to the instance via SSH using this new IPv4 address.
To add an IPv4 address to your instance,
- Login to the instance.
- Use the following command to get the details of the existing public IPv4 address(es) of the instance:
# ip -4 -d addr show
E.g: The IP address for your instance ( CentOS-7 distribution) is 97.64.98.26 with the prefix 24. You will receive an output similar to this:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state
UP group default qlen 1000
inet 97.64.98.26/24 brd 206.246.84.255 scope global dynamic eth0
valid_lft 85681sec preferred_lft 85681sec - Add the new IP address via the following command "ip addr add <ip address/prefix> dev <interface name>".
# ip addr add 97.64.98.36/24 dev eth0
- You should be able to PING or login to the instance via SSH using this new IPv4.
- Make this change persistent as per the distribution.
You can pick an appropriate distribution for your instance depending on your required usage, features, and resource configuration. An IPv4 address can be added to your instance as per the specific distribution.
Add an IPv4 address to your instance for a specific distribution as follows:
- CentOS-7
- CentOS Stream 8, CentOS Stream 9, Fedora, Rocky Linux and Alma Linux
- OpenSUSE
- Ubuntu
- Debian & Ubuntu 16.04
CentOS-7
- Open and edit the file "/etc/sysconfig/network-scripts/ifcfg-eth0":
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
- Add the below contents:
BOOTPROTO=static
Comments:
GATEWAY=97.64.98.1
IPADDR0=97.64.98.26
PREFIX0=24
IPADDR1=97.64.98.36
PREFIX1=24
The GATEWAY address is available in the instance networking section
IPADDR0 is the main IPv4 of the instance
IPADDR1 is the newly added IPv4 to the instance
Do not make any changes to IPv6 address related entries
CentOS Stream 8, CentOS Stream 9, Fedora, Rocky Linux and Alma Linux
- Make the Primary IP assigned to your instance as static.
Note: Below commands need to be executed only once, subsequent configurations
to assign IPv4 addresses can be done directly.# nmcli con mod "System eth0" ipv4.addresses 97.64.98.26/24
# nmcli con mod "System eth0" ipv4.gateway 97.64.98.1
# nmcli con mod "System eth0" ipv4.method manual
# nmcli con mod "System eth0" connection.autoconnect yesComments:
The GATEWAY address is available in the instance networking section - Add the additional IPv4 address.
# nmcli con modify "System eth0" +ipv4.addresses 97.64.98.36/24
- Restart the instance.
OpenSUSE
- Open and edit the file "/etc/sysconfig/network/ifcfg-eth0" by adding the default and new IPv4 address entries.
# vi /etc/sysconfig/network/ifcfg-eth0
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=dhcp
DHCLIENT6_MODE=info
LLADDR=fa:16:3e:65:8b:5a
MTU=1500
STARTMODE=auto
IPADDR_0=97.64.98.26/24
IPADDR_1=97.64.98.36/24Note: Here, you should add the default/main IPv4 address as IPADDR_0
along with the new IPv4 address as IPADDR_1.
Ubuntu
Follow the steps below for the given distributions:
Ubuntu | 22.04 LTS, 20.04 LTS, 18.04 LTS |
- Make a copy of the "/etc/netplan/50-cloud-init.yaml" file as "multiple-ips-init.yaml".
# cp /etc/netplan/50-cloud-init.yaml /etc/netplan/multiple-ips-init.yaml
- Open the file "/etc/netplan/multiple-ips-init.yaml" and add the address entries as below:
# vi /etc/netplan/multiple-ips-init.yaml
network:
version: 2
ethernets:
ens3:
dhcp4: false
dhcp6: true
match:
macaddress: fa:16:3e:d9:58:50
mtu: 1500
set-name: ens3
addresses: [97.64.98.26/24,97.64.98.36/24]
gateway4: 97.64.98.1Note - Here, you should add the default/main IPv4 address along with the
new IPv4 address, set dhcp4 to false and provide the gateway address. - Apply the net plan to have multiple IP addresses.
# netplan apply
Debian & Ubuntu 16.04
Follow the steps below for the given distributions:
Debian |
11,10,9 |
Ubuntu | 16.04 LTS |
- Make a copy of the file "/etc/network/interfaces.d/50-cloud-init.cfg" as "multiple-ips-init.cfg".
# cp /etc/network/interfaces.d/50-cloud-init.cfg \
/etc/network/interfaces.d/multiple-ips-init.cfg - Open the file "/etc/network/interfaces.d/multiple-ips-init.cfg" and add the address entries as below:
# vi /etc/network/interfaces.d/multiple-ips-init.cfg
auto lo
iface lo inet loopback
dns-nameservers 8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
auto ens3
iface ens3 inet static
mtu 1500
address 97.64.98.26/24
gateway 97.64.98.1
auto ens3:1
allow-hotplug ens3:1
iface ens3:1 inet static
address 97.64.98.36/24
Remove IPv4 address Assigned to Your Instance
You can remove an IPv4 address assigned to your instance, and you will not be able to login to the instance via SSH using the IPv4 once it is removed.
To remove an IPv4 address,
- Login to the instance.
- Use the following command to get the details of the existing public IPv4 address(es) of the instance:
# ip -4 -d addr show
E.g: The IP address for your instance ( CentOS 7 distribution) is 97.64.98.26 with a prefix 24. You have an additional IP address associated with the instance that is 97.64.98.36 with a prefix 24. You will receive an output similar to this:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state
UP group default qlen 1000
inet 97.64.98.26/24 brd 206.246.84.255 scope global dynamic eth0
valid_lft 85681sec preferred_lft 85681sec
inet 97.64.98.36/24 brd 206.246.84.255 scope global dynamic eth0
valid_lft 85681sec preferred_lft 85681sec - Remove the IP address via the following command "ip addr del <ip address/prefix> dev <interface name>".
# ip addr del 97.64.98.36/24 dev eth0
- You should not be able to PING or login to the instance via SSH using this IPv4.
- Make this change persistent as per the distribution.
An IPv4 address that is assigned to your instance can be removed as per the specific distribution.
Remove an IPv4 address assigned to your instance for a specific distribution as follows:
- CentOS-7
- CentOS Stream 8, CentOS Stream 9, Fedora, Rocky Linux and Alma Linux
- OpenSUSE
- Ubuntu
- Debian & Ubuntu 16.04
CentOS-7
- Open and edit the file "/etc/sysconfig/network-scripts/ifcfg-eth0" file.
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
- Remove the entries from the file for the IPv4:
BOOTPROTO=static
GATEWAY=97.64.98.1
IPADDR0=97.64.98.26
PREFIX0=24
IPADDR1=97.64.98.36
PREFIX1=24
CentOS Stream 8, CentOS Stream 9, Fedora, Rocky Linux and Alma Linux
- Remove the additional IPv4 address configured on the instance.
# nmcli con modify "System eth0" -ipv4.addresses 97.64.98.36/24
- Reboot the instance to apply the configuration.
# shutdown -r now
OpenSUSE
- Open and edit the file "/etc/sysconfig/network/ifcfg-eth0" to remove the entries for IPv4 address.
# vi /etc/sysconfig/network/ifcfg-eth0
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=dhcp
DHCLIENT6_MODE=info
LLADDR=fa:16:3e:65:8b:5a
MTU=1500
STARTMODE=auto
IPADDR_0=97.64.98.26/24
IPADDR_1=97.64.98.36/24
Ubuntu
Follow the steps below for the given distributions:
Ubuntu |
22.04 LTS, 20.04 LTS, 18.04 LTS |
- If you have more than two IPv4 addresses assigned to your instance, you can un-assign a specific address by removing it from the
"/etc/netplan/multiple-ips-init.yaml" file as below:
E.g:
network:
Or if you have only one additional IPV4 address, remove the file
version: 2
ethernets:
ens3:
dhcp4: false
dhcp6: true
match:
macaddress: fa:16:3e:d9:58:50
mtu: 1500
set-name: ens3
addresses: [97.64.98.26/24,97.64.98.36/24,97.64.98.46/24]
gateway4: 97.64.98.1
"/etc/netplan/multiple-ips-init.yaml".
# rm /etc/netplan/multiple-ips-init.yaml
- Apply the net plan to remove the additional IP address.
# netplan apply
Debian & Ubuntu 16.04
Follow the steps below for the given distributions:
Debian |
11,10,9 |
Ubuntu | 16.04 LTS |
- If you have more than two IPv4 addresses assigned to your instance, you can un-assign a specific address by removing it from the "/etc/network/interfaces.d/multiple-ips-init.cfg" file.
E.g:
auto lo
Or, if you have less than two additional IPv4 addresses, remove the file
iface lo inet loopback
dns-nameservers 8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
auto ens3
iface ens3 inet static
mtu 1500
Address 97.64.98.26/24
gateway 97.64.98.1
auto ens3:1
allow-hotplug ens3:1
iface ens3:1 inet static
address 97.64.98.36/24
auto ens3:2
allow-hotplug ens3:2
iface ens3:2 inet static
address 97.64.98.46/24
"/etc/network/interfaces.d/multiple-ips-init.cfg".
# rm /etc/network/interfaces.d/multiple-ips-init.cfg
- Reboot the system to remove the additional IP address permanently.
# shutdown -r now