0

So I issued a command ip a which list all the IP addresses. However I don't understand what all the other Ip addresses and details it printed. In this output I just understood that inet W.X.Y.Z/20 brd is my machine's IP address under eth0. What about the IP address and details under lo and eth1. From one of the blog I understood that inet A.B.C.D/16 brd is my private address but none of them explains what other things are.

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:10:9f:10:ad:10 brd ff:ff:ff:ff:ff:ff
    inet W.X.Y.Z/20 brd W.X.79.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet A.B.C.D/16 brd A.B.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 2400:abab:100:ab::ab:5001/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::abab:9fff:abab:add2/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 9a:ab:ab:40:13:a5 brd ff:ff:ff:ff:ff:ff
    inet Q.W.E.R/20 brd Q.W.15.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 f56g::abab:a5ff:abab:13c5/64 scope link
       valid_lft forever preferred_lft forever

EDIT: Updated the actual result of ip a

root@ubuntu-s-1vcpu-1gb-blr1-01:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:a0:9f:54:ad:d2 brd ff:ff:ff:ff:ff:ff
    inet 139.59.75.106/20 brd 139.59.79.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 10.47.0.5/16 brd 10.47.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 2400:6180:100:d0::db:5001/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::50a0:9fff:fe54:add2/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 9a:4b:a5:40:13:c5 brd ff:ff:ff:ff:ff:ff
    inet 10.122.0.2/20 brd 10.122.15.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::984b:a5ff:fe40:13c5/64 scope link
       valid_lft forever preferred_lft forever
Himanshuman
  • 241
  • 1
  • 6

1 Answers1

3

You don't have "the one ip". Every network interface in your machine can have multiple IPs. A machine has usually one or two network interfaces. You have three.

lo

This is your loopback device, this is (with exceptions) always there. It is the interface that your machine uses when it wants to talk to itself (127.0.0.1).

eth0 & eth1

It seems that you have two more interfaces. Every one of these can have multiple ip addresses. The IPs you are referring to (X.X.X.X/XX) are IPv4 addresses. The other ones (e.g. 2400:abab:100:ab::ab:5001/64) are IPv6 addresses. If you want further information about these, I suggest you read the Wikipedia articles on both, they are quite extensive and well writen.


My guesses regarding your IPs (without knowing what the actual IPs are):

127.0.0.1     IPv4 localhost (not a guess)
::1/128       IPv6 localhost (not a guess)
W.X.Y.Z/20    Maybe your actual public ip. Some ISPs do that (although it's dumb)
A.B.C.D/16    probably your local private IPv4. Probably a 10.0.X.X address
2400:abab:    Your public IPv6 address. This is mostlikly a public routed IP
fe80:...      Your private IPv6 (The IPv6 equvalent of A.B.C.D/16)
Q.W.E.R/20    no idea without knowing what the actual IP is
f56g::abab:   Again probably a public routed IPv6
Malik
  • 231
  • 1
  • 9
  • My question was not if they are IPv4 or IPv6 address, my question what are they and what are they used for and obviously I don't just have 2 IP addresses in that list, there are multiple addresses there! – Himanshuman May 12 '22 at 07:00
  • Oh sorry, it seems I understood your question the wrong way. I still sugget you looking up on the IPv4 and IPv6 wikipedia article, as your questions will probably be partially answered there. I will still edit my answer and add my guesses there. – Malik May 12 '22 at 07:06
  • `My guesses regarding your IPs (without knowing what the actual IPs are):` No one is going to expose their actual P/P IPs here! – Himanshuman May 12 '22 at 07:42
  • 2
    1. The private IP of someone is really irellevant. For example my private ip is currently 192.168.178.41. There you go, what are you going to do with this now? 2. OP could anonymize is public ips. For example 185.213.XXX.XXX This way, we know what kind of IP it is, without actually knowing the IP. – Malik May 12 '22 at 07:45
  • For public IP addresses you can just use one from the "example" IP subnets referenced in RFC 5737, for instance 192.0.2.42. – dr_ May 12 '22 at 07:52
  • @DeveloperP It's really hard to guess what's going on without knowing more about the networks your computer's connected to. The setup looks pretty unusual to me, especially the f56g:: IPv6 address on eth1 -- that's not part of any valid type I know of. – Gordon Davisson May 12 '22 at 07:57
  • @PulkitBhatnagar I don't mind exposing my IP addresses, Malik do you want me to share the entire result? – Himanshuman May 12 '22 at 08:52
  • That would be a great help. @GordonDavisson I think op anonymized the IPs, so that is probably just a bogus ip address. But still, this is a unusual setup. – Malik May 12 '22 at 08:59
  • @GordonDavisson , Malik updated my question, check EDIT – Himanshuman May 12 '22 at 09:17
  • @DeveloperP The 139. and 2400: addresses are public, and the 10. and fe80:: addresses are private (local-only) addresses. Having both on the same interface (eth0) is totally normal for IPv6, and unusual but valid for IPv4. From the public IP, this looks like a Digital Ocean host, and the extra interface and private IPs are probably part of their hosting infrastructure. – Gordon Davisson May 12 '22 at 18:28
  • I am not sure, but the private IP address is not visible in when I issue ``ifconfig` command. Is it expected? – Himanshuman May 13 '22 at 05:13