But what's going to happen if I visit the LAN IP address assigned by the network administrator, compared to visiting localhost?
Will it go ask the router/gateway about who e.g. 111.111.111.111 is?
No. Generally, the OS will realize that it owns the destination address, and will not send the packets anywhere outside.
For example, on a Linux system, this happens through the routing table – if you look at the local
table, you'll see all assigned IP addreses having /32 routes pointed at the 'lo' interface.
In other OSes such as Windows or BSDs, the mechanism may be more opaque, but the end result is nevertheless the same. (The only exception is when using "jails", "containers", "network namespaces", or "VRFs" – each instance only recognizes its own IP addresses, and not those belonging to other jails/containers.)
Whether the address is "public" or "private" does not matter.
And could the router fool/tell it that 111.111.111.111 is outside the LAN and tell it go out to find it? More precisely, can NAT routes LAN 111.111.111.111 to the public, real 111.111.111.111?
If it exactly matches your computer's IP address – no. The computer won't even contact the router in the first place.
If it's in the same subnet as your computer's IP address – possible, but with difficulties. The router would need Proxy-ARP in addition to NAT. It should be doable with Linux iptables in theory, but I'm not sure if any end-user routers have that feature built in.
I am asking this because I think my ISP gives me a public IP as LAN IP address (less possible that I truly connect to that public IP)
It is normal that ISPs issue public IP addresses, and that's because ISPs do not generally issue LAN IP addresses: that's the job of your router. The ISP only provides initial configuration for that router (and only if the device itself is ISP-provided). The router itself, of course, gets its address from the ISP.
It is possible that the provided device is actually just a bridge (or a router in bridge mode), in which case receiving public IP addresses is completely normal.
That said, some ISPs are known for "borrowing" previously-unused IP space. For example, the range 1.0.0.0/8 sat nearly-unused for many years (until CloudFlare picked it up), so various network admins sometimes decided to use it as an extension of the standard private address ranges. In those situations, best to contact customer service and submit a specific complaint that you're unable to reach some specific service at the overlapped addresses.
(Note that the range 100.64.0.0/10 is not public, quite the opposite. It's a private range meant to be used strictly between the ISP and its customers, in situations where they don't have any public IP address.)
1Note: cloudflare has 1.1.1.0/24 and 1.0.0.0/24 (obtained under a special arrangement with apnic), not the 1.0.0.0 prefix as a whole. Other parts of that prefix are assigned to regular ISPs. – plugwash – 2019-07-03T20:03:50.900
Thank you so much for your detailed explanation. I totally get what I want from your answer. Btw, how do I see that "if you look at the local table, you'll see all assigned IP addreses having /32 routes pointed at the 'lo' interface." you describe? I run
sudo ip route
(I am using Ubuntu), and I only get : – Rick – 2019-07-04T01:10:29.607default via 192.168.0.1 dev enp3s0 proto dhcp metric 100 169.254.0.0/16 dev enp3s0 scope link metric 1000 192.168.0.0/24 dev enp3s0 proto kernel scope link src 192.168.0.107 metric 100
I don't see any ip with /32 prefix. – Rick – 2019-07-04T01:10:59.987My question is based on my actual experience I encoutered.Why can my ISP use 172.39.x.x as local network IP?. Take a look if you're interested (opnions are appreciated of course :D). Without more information or confirmation from my ISP, I really can't tell whether I am truly connecting to that public IP or not.
– Rick – 2019-07-04T01:17:07.897@Rick: Do you mean the appearance that your ISP (China Mobile) uses 172.39.0.1 in what appears to be the ISP's internal network? That seems to be a completely different situation from what you've asked here. – user1686 – 2019-07-04T10:10:52.877
Ah, they are quite related I think. I care more about the technical stuff behind the situation I have. Your answer totally satisfies my need. :D – Rick – 2019-07-04T10:19:00.927
Most of 'the technical stuff' doesn't apply to that topic, either. – user1686 – 2019-07-04T10:20:06.287