3

Command for determining my public IP?

According to "Michael K" who answered the question my computer won't know the public Ipv4 address but it somehow knows the public ipv6 address. Why is that so? executing the command ìp a shows my public ipv6 address.

3 Answers3

5

The following commands will get you the public IP addresses for your machine:

curl ifconfig.me

curl ifconfig.me/ip

curl ifconfig.me/all

akshahi17
  • 104
  • 1
  • 6
1

I will try to describe this the best I can.

It really all depends on what supplies IPs to your host. For most home users they use a router that has a built-in DHCP server thus allowing more than one system online through using 1 IP address. You can setup a computer as a router too. If you have only 1 computer you could bypass the router all together and hook up your system directly to your broadband modem. IPv4 vs IPv6 are two completely different ways of doing IP addresses.

A decent read https://www.thousandeyes.com/learning/techtorials/ipv4-vs-ipv6

IPv4 is a 32-bit way of addressing and is limited as to how many unique IP addresses there are total (just over 4 billion). Where IPv6 is 128-bit allowing 340000....0000 (37 zeros after the 34, it's a big number) where you can have your own unique IPv6 public IP for every single device in your house connected to your router, even your router would have its own public IP.

So, to keep allowing for IPv4 addressing, they have created it so that a public IP on IPv4 to a single location uses 1 IP, then NAT takes over with the DHCP allowing you to create more IPs behind the public IPv4 allowing you to have more and more systems using the same public IP.

Terrance
  • 43,712
1

IPv4 has a limited number of available addresses. So folks use a blinky-box-router so their entire network shares a single one of those limited public IPv4 addresses.

Honestly, that's a hack. However, it's a hack that we are all familiar with and take rather for granted.

When connecting using IPv4, that router is in the way.

IPv6 has a much greater number of available addresses, so every item on your local network has it's own public IP addresses...which is (oversimplifying) the same as it's LAN IP address. There's no longer an important difference, and there's no need for that hack anymore. The same blinky-box functions as a mere switch instead of a router.

When connecting using IPv6, that router is not in the way anymore.

user535733
  • 68,493