Tunneling through captive portals with DNS


Imagine you are sitting in an airport, and you feel a sudden urge to browse the Internet. You take out your phone, and there seems to be an open network for travelers. Having safety in mind, you fire up your VPN client. But wait - It can’t connect? You open your browser and witness a horrible sight when you try to look something up in DuckDuckGo…

“Damn!”, you say to yourself. “I don’t want to pay for that! There has to be a way…”

Enter DNS tunneling!

DNS is, in short, a service to translate domain names, such as 0x00sec.org, to IP adresses, such as A typical exchange looks like this:

  1. Client sends a UDP packet containing the domain name to translate.
  2. Server replies with the IP address corresponding to the domain.

There are more DNS record types, for example TXT, which allow the server to respond with arbitrary data instead of an IP. Now, someone smart thought to themselves, would it be possible to communicate using DNS requests and replies? As it turns out, it is! Imagine something like the following:

  1. Client sends a DNS packet of type TXT containing “hello-server.domain.tld”
  2. Server receives the packet, reads data from the request and sends back “hello-client”

See where this is going? Now, let’s go a step further and create (almost) a full blown VPN! With some base64 or other encoding sprinkled in, you can send whole IP packets encapsulated in DNS requests. Here’s an example:

  1. Client reads a packet from a TUN device, encodes it and sends a request containing the packet to the server. Let’s say it’s a SYN packet to 0x00sec.org.
  2. Server receives the request, and decodes the packet.
  3. The packet’s source address is changed to indicate the server’s address, so replies go back to the server instead of the client.
  4. The packet is then sent on its way, and a reply shortly arrives: a SYN/ACK packet!
  5. Packet source is changed back to client so his networking software doesn’t bitch about malformed packets and other such frivolities. It’s then encoded into a DNS reply and sent back.
  6. Client receives the SYN/ACK and writes it into the tun device.

Now the client’s browser/netcat/metasploit will respond with an ACK packet and a connection will be estabilished. There’s a caveat, though. What if the server needs to send data? It can’t just send another DNS reply, as the client’s router won’t route it to the client anymore. The solution is a bit hacky but simple: the client just needs to send an empty DNS request every so often, so the server can reply with the data.

It might look simple on paper, but the implementation is somewhat difficult. Trust me, I tried. Thankfully, there already are programs for DNS tunneling. The one I’m using is called Iodine. You can install it by using apt-get install iodine. Here’s what you will need:

  1. A server and client. They’re both included in the iodine package.
  2. A domain name, with the ability to set nameservers. You can get one from dot.tk.
  3. Another couple domains to set up nameservers.
  4. A computer you can forward port 53 to.

You’ll have to set up nameservers to domains which point to your iodine server.

Setting up is quite simple. On the server, run:
iodined -P <strong password> <IP of tun device> <domain>
for example, iodined -P 1234 tunnel.tk

On the client, run:
iodine -P <password> <domain>
for example, iodine -P 1234 tunnel.tk

And voila! Free internet access everywhere! (Unless the router doesn’t fall for it and blocks all DNS queries, but shh…)

How does those hackers tools work?. VPNs
(oaktree) #2

This is pretty 1337, but it sounds expensive.


This can’t be real. The legend himself @Joe_Schmoe made a write-up? Dayum!


.tk domains are free.

(oaktree) #5

Computers aren’t, though. And I would not wanna use one of those dot.tk spam domains.


You can run iodined on your main computer while away on holidays or a raspberry pi. It takes up barely any resources.

If you don’t want to use dot.tk domains you can use any other free domain services, but you need to be able to change nameservers.

(oaktree) #7

@Joe_Schmoe What does changing nameservers entail?

(Full Snack Developer) #8

Iodine is pretty dope, but the thing that killed me with it is that you need to be prepared ahead of time to use it. I found myself stuck in an airport and wanted to tunnel out, but didn’t have iodine or a gateway. RIP.

(Full Snack Developer) #9

However, if we’re strictly talking about evading captive portals, most have a free tier that lasts 30 mins or so. Use macchanger to generate a new mac and refresh your session

(Command-Line Ninja) #10

That’s what I do the majority of the time. In the past I have spoofed Mac addresses of of the people who have paid, but @py doesn’t believe I pulled it off.

(Command-Line Ninja) #11

DNS records man! Cmon.

(Full Snack Developer) #12

That sort of attack is in theory not that hard to pull off. Just sniff for someone who is clearly browsing past the paywall, send a ton of DEAUTH frames, wait until they get pissed and give up, then take over their mac.



It is possible. The way you described it seemed like you and the victim were sharing the same MAC address while BOTH connected, which will fail.

@fraq’s description sounds feasible because the user will be kicked off the network.

(Command-Line Ninja) #14

Perhaps I was lucky? Where that person had left just as I connected? Or perhaps the access point would disconnect the user in favour for the new user?

Hm who knows. Does anybody know the rules around what happens when a device connects to an access point with the mac address of an exisiting device?


I read this a few months ago in my online newspaper. Maybe a time saver, a lot less l33t way to get on the airport wifi: http://mashable.com/2016/10/06/airport-wifi-map/#2eMsSLDm7qqw

(Valentine) #16

Nice post. This might come useful. Muahhaha! :smile:


I do this also. It works in most hotels.