Quick Fix for Public WiFi on Linux

Author

Luke

Published

December 1, 2024

Public Wi-Fi Woes

As of the time of writing, I run Debian with KDE on my little Lenovo laptop. Before that, I was using Debian server… In other words, I installed everything from scratch. The reason for this bare-bones approach was mostly to see what it’s like to live without a desktop environment. This had some niceties, like being extremely lightweight and fully embracing the power of my window manager at the time (Qtile). However, it also had plenty of downsides, such as constantly being caught out when having to spontaneously connect to a device I hadn’t connected before. I simply didn’t (and still don’t) have the necessary experience that would allow me to solve these issues on the fly without some research. In my life as a PhD student these off-guard moments happened quite often, for example when giving any sort of presentation. That’s why I ended up returning to the Desktop Environment world - to benefit from the convenience of someone else having thought of all the little things that I might run into in my daily life. Sometimes, “bloat” is the price you pay for convenience.

Despite using a desktop environment again, which is probably what 90% of Linux users do, there are still odd occurrences that seem to catch the pre-configured settings off guard. One that I frequently experience recently is some failure when connecting to many public Wi-Fi networks. From what I understand, these issues arise because the captive portal (the login page for the public Wi-Fi) is sometimes separate from the network that you connect to, and sometimes the network doesn’t automatically redirect you to the captive portal. This is a problem because the network manager doesn’t know that you need to log in, so it just sits there trying to connect to the internet, but you’re never actually getting online. Even more confusingly, some public Wi-Fis are set up differently than others, so even when you found a solution for one public Wi-Fi giving you headaches, it does NOT mean that the same solution will work for all other public Wi-Fis. If you’re in a situation where the frequently recommended solution does not work, it can be pretty frustrating. This is why I’m writing this post - to document the solutions that I’ve found for the public Wi-Fis that I’ve encountered. I think these are worth documenting locally on your device for quick reference when in a pinch. I actually only have three tricks up my sleeve, but have yet to encounter a network that I couldn’t connect to with one of these. I hope they help you too!

ip route

The command ip route is a command that shows the routing table of the device. This is useful for a number of reasons, but in this case, it’s useful because it can show you the IP address of the network that you’re connected to. FYI, IP addresses are the unique identifiers for devices on a network, and are formatted as a series of numbers separated by periods. The routing table is useful because sometimes the network manager will say that you’re connected to the network, but you’re not actually connected to the internet. Again, this is because the network manager doesn’t know that you need to log in, so it just happily sits there. If you run ip route and see that you’re connected to the network, but you’re not connected to the internet, then you know that you need to log in. This is the first step to solving the problem. One of the IP addresses listed will be the IP address you are connected to, while the others will be other IP addresses you can connect to in the network. The trick is simply to pick one of the addresses listed, open a browser, and paste in the IP address as the URL. If you picked the right address, this should redirect you to the captive portal, where you can log in. If you’re not redirected, try another IP address from the list. If you’re still not redirected, then you might have to try one of the other tricks. FYI, to copy from the terminal, you can use Ctrl+Shift+C. What’s nice about this command is that ip route is a standard command that comes with most Linux distributions, so you don’t have to install anything to use it. Additionally, you do not need to be root to run this command.


Example output of ip route:

default via 192.168.1.1 dev eth0 proto dhcp metric 100 
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.100 metric 100 


route -n

route -n is very similar to ip route, but it’s a bit more user-friendly. The approach is the same as before, connecting to IP addresses in your browser with the hope of triggering the captive portal. The output will look something like this:


Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 eth0


For some reason I don’t know, when ip route fails this command sometimes can save you because what you need to redirect to is not the IP addresses in the Destination column, but one listed in one of the other columns. I don’t know why this is the case, but it’s worth a shot if ip route didn’t work. Again, you don’t need to be root to run this command, which is nice, but this one is less likely to come pre-installed on your machine. If you don’t have it, maybe try hot-spotting from your phone to download it when in a pinch, or pre-emptively install it before you’re likely to need it.


Outdated websites ?!

This last trick I figured out while stuck at an airport in the US. For some reason, both ip route and route -n failed me, and I was getting pretty desperate. I was browsing obscure Linux forums on my phone, ready to just take the hit. Some dude somewhere in the depths of this forum essentially just suggested connecting to an outdated website. For some reason I don’t know (as no explanation was offered), this actually solved my problem. So the trick is very simple - bookmark a website you trust that hasn’t switched to HTTPS yet (and optimally is not intending to switch), and try to connect to it. If you’re lucky, this will redirect you to the captive portal. I want to emphasize that you should only do this as a last resort, as your connection will NOT be encrypted.

Some websites that can be used for this purpose include:


Conclusion

I hope this was helpful to you! If I missed anything, or you actually know the more detail about why these tricks work, please let me know in the comments.

Back to top