Assign multiple ip addresses to single network card in linux

It’s apparent which i have assigned class A kind IP series i.e 192.168.1. to my network card. Let’s Say I want an different series, for instance 192.168.2.?

Just run the next command to create an additional IP.

Assign multiple ip addresses to single network card in linux 255 port

$ sudo ip addr add 192.168.2.105/24 dev enp0s3

Here 24 signifies the netmask i.e 255.255.255..

Now, let’s see if the brand new IP continues to be assigned or otherwise.

Assign multiple ip addresses to single network card in linux did to date

$ ip addr

Sample output:

1: lo: mtu 65536 qdisc noqueue condition UNKNOWN group default qlen 1

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127…1/8 scope host lo

valid_lft forever preferred_lft forever

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: enp0s3: mtu 1500 qdisc pfifo_fast condition UP group default qlen 1000

link/ether 08:00:27:12:f8:c1 brd ff:ff:ff:ff:ff:ff

inet 192.168.1.105/24 brd 192.168.1.255 scope global enp0s3

valid_lft forever preferred_lft forever

inet 192.168.2.105/24 scope global enp0s3

valid_lft forever preferred_lft forever

inet6 fe80::a00:27ff:fe12:f8c1/64 scope link

valid_lft forever preferred_lft forever

As you can see within the above output, my network card has two IP i.e 192.168.1.105 and 192.168.2.105. Similarly you are able to assign as numerous additional IPs as you desire i.e 192.168.3.105, 192.168.4.105 etc.

Let’s ping the brand new Ip:

$ sudo ping -c 3 192.168.2.105

Sample output:

PING 192.168.2.105 (192.168.2.105) 56(84) bytes of information.

64 bytes from 192.168.2.105: icmp_seq=1 ttl=64 time=.040 ms

64 bytes from 192.168.2.105: icmp_seq=2 ttl=64 time=.067 ms

64 bytes from 192.168.2.105: icmp_seq=3 ttl=64 time=.066 ms

— 192.168.2.105 ping statistics —

3 packets transmitted, 3 received, % packet loss, time 2000ms

rtt min/avg/max/mdev = .040/.057/.067/.015 ms

Congratulations! It’s working!!

Wait, I haven’t finished yet. What we should did to date is we assigned the brand new IP temporarily. Once you reboot the machine, the brand new IP will disappear. How can you allow it to be permanently? It’s simple too.

Assign multiple IP addresses permanently:

Edit /etc/network/interfaces file:

$ sudo nano /etc/network/interfaces

Now, add some additional Ip as proven below:

iface enp0s3 inet static

address 192.168.2.105/24

Save and shut the file.

Run the next command to consider effect the saved changes.

$ sudo ifdown enp0s3 && sudo ifup enp0s3

Sample output:

Wiped out old client process

Internet Systems Consortium DHCP Client 4.3.3

Copyright 2004-2015 Internet Systems Consortium.

All legal rights reserved.

For information, check out https://www.isc.org/software/dhcp/

Listening on LPF/enp0s3/08:00:27:12:f8:c1

Delivering on LPF/enp0s3/08:00:27:12:f8:c1

Delivering on Socket/fallback

DHCPRELEASE on enp0s3 to 192.168.1.1 port 67 (xid=0xe3877d4)

RTNETLINK solutions: Cannot assign requested address

Internet Systems Consortium DHCP Client 4.3.3

Copyright 2004-2015 Internet Systems Consortium.

All legal rights reserved.

For information, check out https://www.isc.org/software/dhcp/

Listening on LPF/enp0s3/08:00:27:12:f8:c1

Delivering on LPF/enp0s3/08:00:27:12:f8:c1

Delivering on Socket/fallback

DHCPDISCOVER on enp0s3 to 255.255.255.255 port 67 interval 3 (xid=0x3080e44d)

DHCPDISCOVER on enp0s3 to 255.255.255.255 port 67 interval 7 (xid=0x3080e44d)

DHCPREQUEST of 192.168.1.105 on enp0s3 to 255.255.255.255 port 67 (xid=0x4de48030)

DHCPOFFER of 192.168.1.105 from 192.168.1.1

DHCPACK of 192.168.1.105 from 192.168.1.1

certain to 192.168.1.105 — renewal in 42937 seconds.

Now, let’s run the next command to check on if the new Ip continues to be assigned or otherwise.

$ ip addr

Sample output:

Resourse: https://ostechnix.com/how-to-assign-multiple-ip-addresses-to-single-network-card-in-linux/

How to create Multiple IP Address to Single Network interface

Video COMMENTS:
  • Imran Qureshi: Helpfull, but when i added ips range, ips are pinging but not showing on ifconfig / ip a command
  • Tommy TBones Cramer: thank you, I was able to complete the first of several tasks on my Radio Server. I needed an extra ipaddress so I could run CentovaCast on port 80. I did have a bit of trouble understanding your english partly because you are very soft spoken. Tommy