2

I have a 4G router (TP-Link Archer MR200), that tells me in its GUI that it has a public IP of (just an example) 10.194.12.4. If I do curl ifconfig.me, I get a different IP, like 90.153.17.52. As far as I know, this has to do with CGNAT and how my SIM carrier handles SIM IP addresses. However, that IP I get from ifconfig.me (or any other "whats my ip" kind of service) is "wrong", and I can't access my router through it, while I can through the one my router tells me (I have set up port-forwarding and stuff like that).

I am currently trying to write a Python script to automatically update my No-IP dynamic ip correctly (since my router sends the wrong one), and I need to find a way to get that true public IP from the router, but I have found literally nothing regarding how to do that. I have searched for TP-Link APIs or linux utilities that allowed me to get that little bit of information about the router, to no avail, since everything on the internet is either for the public IP that I get from online services like ifconfig.me (the wrong public IP) or for the local IP.

I am planning on writing a web scraper for the router's control panel, but I'd like to know first if there is anything I can do to get the correct IP more easily.

Edit: I want to make a clarification: I have set up port forwarding to be able to SSH to my computer remotely. I can do ssh user@10.194.12.4 without problems, exactly as I would do on a local network. I cannot do the same with the 90.x.x.x IP. That's why I refer to the 10.x.x.x IP as the true public IP and the 90.x.x.x as the wrong one. My network is perfectly reachable through the 10.x.x.x IP.

Edit 2: Nevermind, I've just figured out I have been accessing the network from networks under the same ISP, so I've been unknowingly accessing my computer over a really big LAN and not over the actual Internet >:P

3
  • Does your router support SNMP? Note that by including your router model my question would be abundant. Aug 13 at 19:45
  • @mashuptwice It does indeed support it Aug 13 at 20:47
  • Then check with a SNMP browser if your router exposes the WAN IP. Before you proceed, can you confirm that it is possible to SSH into your machine from a remote network, e.g. using a VPN or your phones hotspot? Note that if you are in the EU, your carrier is obligated to provide you a "true" public IPv4 address upon your request. It takes no more than an email, 1-2 days time and a APN change to set it up. Aug 13 at 20:56

3 Answers 3

5

The IP Address 10.x.x.x falls within the Internet's Private or Reserved IP Address Space. There is no way that you can access it from the internet. It's allocated by your ISP for your use, but has no validity outside of the ISP's local network.

The IP address of 90.153.17.52 is probably the right IP address, but you most likely share it with other users of your ISP, because that's how CGNAT works. So it also can't be used to reach your computer from the internet.

The only way you can make your computer reachable from the internet, is to ask your ISP for a static IP address, which may require additional payment. Once you get that static address, both the methods that you used will result in the same IP address, and there won't be any "wrong" one.

Reference : Wikipedia Carrier-grade NAT (CGN or CGNAT).

9
  • 2
    "The only way you can make your computer reachable from the internet, is to ask your ISP for a static IP address, which may require additional payment." There's also stuff like ngrok.com.
    – ceejayoz
    Aug 14 at 5:03
  • @ceejayoz: Interesting.
    – harrymc
    Aug 14 at 8:25
  • 1
    @justhalf As originally designed, not just every router, but every computer on the Internet should have a unique IP address. However, it turns out that we quickly out-grew the 4 billion addresses available in IPv4, particularly because they weren't allocated very carefully early on, so often ISPs reuse addresses for multiple users, which is the "CGNAT" referred to in the answer. It's certainly not required for them to do so, though, so it's possible you're lucky and have a unique address.
    – IMSoP
    Aug 14 at 14:25
  • 2
    Small nitpick: a static IP address is a slightly stronger requirement than a dedicated address: when I was first online, in 1990s UK, it was common for dial-up ISPs to have a pool of addresses used on a "time-share" basis, so that you'd be allocated one each time you connected, but it would be directly routable back to you for the duration of that connection. A static address was one that was allocated even when you weren't using it. Modern DSL and fibre lines generally have an always-connected home router; but such a scheme could still be used for mobile connections, for instance.
    – IMSoP
    Aug 14 at 14:29
  • 1
    @justhalf Remember that this site is not a forum - this comment section is for improving this particular answer, not having an extended discussion inspired by it. There's a Wikipedia link in the answer describing how Carrier-Grade NAT works, and plenty of other explanations online; if they leave you with a specific question, maybe you can ask it on a new page.
    – IMSoP
    Aug 14 at 14:54
2

The reason you haven't found anything regarding obtaining the "true" public IP address is simply because your router does not have a public IP address at all.

The 10.x.x.x address shown in its GUI is a private address (despite the GUI calling it "public"), but nevertheless it's the real address that the router was assigned by your ISP (SIM carrier).

What's shown by "what is my IP" services is not wrong either – it's the address used by your ISP's NAT gateway, which is exactly what those services are meant to report. (Your router being inside the ISP's global CGNAT is exactly like your computer having a private address and being inside the router's local NAT, and external services have no way to distinguish the two situations.)

So in other words, your ISP has not issued you any IPv4 address that you could use to access your 4G router externally. You would need to call them and see if they offer a dedicated public IP address as an extra service.

2
  • Then how am I able to access all of the services I expose on my network (using port forwarding and such) on the 10.x.x.x IP? Aug 13 at 20:49
  • 2
    @CiroGarcía: I assume you're accessing them either from within the network itself, or from another system connected to the exact same ISP, which is therefore in the same 10.x.x.x network as your 4G router. ("Private address" does not mean "LAN address"; if the ISP wants to use private addresses across the entire country it can perfectly well do so. So in the case of CGNAT it's normal that one customer's device could still connect to another.)
    – user1686
    Aug 13 at 20:53
0

Others have discussed the nature of your problem. Here is one solution to circumvent the fact that you don't really have an IP per se: if IPv6 is an option, you may retain the services of an IPv6 broker, of which there are many. As an example. Hurricane Electric offers a free IPv6 broker. On the surface, it works like a VPN, but instead a huge IPv6 address block is assigned to you. Under the hood, various optimizations are performed. Since a lot of brokers are big players located in many datacenters, they can route your traffic efficiently without requiring your packets to go far.

https://ipv6.he.net

2
  • 1
    Hurricane Electric might not be a very good choice here, as having a public IPv4 address is kind of a prerequisite for HE, and IP-in-IP tunnels aren't very reliable when the endpoint is behind a NAT. For mobile 4G users, some kind of UDP-based tunnel (e.g. WireGuard) would be a better option.
    – user1686
    Aug 14 at 12:50
  • Ah, I was not aware, thanks.
    – sleblanc
    Aug 15 at 3:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.