Posted: . At: 7:37 AM. This was 1 year ago. Post ID: 17769
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to add a second IP address to the loopback device.


Adding a second IP address to the loopback device is pretty easy. This is possible using the ip(1) command.

┗━━━━━━━━━━┓ john@localhost ~
           ┗━━━━━━━━━━━━━╾ ╍▷ su
Password: 
[root@localhost john]# ip addr add 192.168.1.8 dev lo
[root@localhost john]#

This has added a second IP address to the loopback device.

┗━━━━━━━━━━┓ john@localhost ~
           ┗━━━━━━━━━━━━━╾ ╍▷ ip a | grep inet
    inet 127.0.0.1/8 scope host lo
    inet 192.168.1.8/32 scope global lo
    inet6 ::1/128 scope host 
    inet 192.168.1.2/24 brd 192.168.1.255 scope global dynamic noprefixroute enp0s25
    inet6 fdc8:1451:5fa9:4700:d250:99ff:fe0d:ab0f/64 scope global dynamic noprefixroute 
    inet6 fe80::d250:99ff:fe0d:ab0f/64 scope link noprefixroute

This goes to show that we can have a second IP address on a loopback device.

It is even possible to add yet another IP address.

┗━━━━━━━━━━┓ john@localhost ~
           ┗━━━━━━━━━━━━━╾ ╍▷ ip a | grep inet
    inet 127.0.0.1/8 scope host lo
    inet 192.168.1.8/32 scope global lo
    inet 192.168.1.9/32 scope global lo
    inet6 ::1/128 scope host 
    inet 192.168.1.2/24 brd 192.168.1.255 scope global dynamic noprefixroute enp0s25
    inet6 fdc8:1451:5fa9:4700:d250:99ff:fe0d:ab0f/64 scope global dynamic noprefixroute 
    inet6 fe80::d250:99ff:fe0d:ab0f/64 scope link noprefixroute

This is a very impressive Linux trick.

I am not sure how useful this is, but it is interesting anyway.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.