[email protected]Office hours: Mon – Fri 9:00AM – 5:00PMLinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedFebruary 21, 2023

How to add a second IP address, permanent or temporary in Linux

How to add a second IP address, permanent or temporary in Linux

 

Add a second temporary IP address

  • Using ifconfig

If you want to add a secondary IP address to a NIC already in use in Linux, and have that change only temporary. Enter this command:

ifconfig [nic]:0 [IP-Address] netmask [mask] up

An example is shown below

ifconfig eth0:0 192.168.1.2 netmask 255.255.255.0 up

You need to be root in order to execute that command.

  • Using ip command

If you prefer to use the ip command instead of ifconfig

ip address add [ip]/[mask-digits] dev [nic]

Here is an example

ip address add 192.168.99.37/24 dev eth0

With this command you can add more ip address to the same dev NIC, the second is considered as secondary.

 

Add a permanent IP address

Ubuntu

For Ubuntu systems, edit the /etc/network/interfaces file

vim /etc/network/interfaces

Add this for one extra IP

auto [NIC]:[n]

iface [NIC]:[n] inet static

address [ip.add.rr.ss]

gateway [gw.ip.ad.rs]

netmask [ne.tm.as.kk]

Here an example:

auto eth0:1

iface eth0:1 inet static

address 192.168.0.1

gateway **********

netmask 255.255.255.0

You can add as many blocks as you want. Just change eth0:1 for eth0:2, eth0:3 and so on.

If you are adding additional IPs to eth1, or eth2 also modify that on the example.

Keep reading
How to Implement Network Segmentation and Resource Isolation in Linux.
February 6, 2024

How to Implement Network Segmentation and Resource Isolation in Linux.

How to Implement Network Segmentation and Resource Isolation in Linux. Securing and managing networks in a Linux environment involves advanced practices like network segmentation and resource isolation. This guide explores these concepts, providing detailed instructions and examples for…

Read article
How to open or close ports in Linux.
February 6, 2024

How to open or close ports in Linux.

How to open or close ports in Linux. Effectively managing ports on your Linux system is crucial for both security and service accessibility. This comprehensive guide will provide a detailed walkthrough on opening and closing ports using the robust tools iptables and ufw. Understanding these…

Read article
How to use ypdomainname command.
January 23, 2024

How to use ypdomainname command.

How to use ypdomainname command. In the realm of Linux networking, the ypdomainname command plays a crucial role in the context of the Network Information Service (NIS). NIS, formerly known as Yellow Pages, is a distributed database service that facilitates the sharing of network configuration and…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, colocation, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Office hours: Mon – Fri 9:00AM – 5:00PM