Raspberry Pry - Offline Communications Network


(Command-Line Ninja) #1

Picture the moment. It’s 2057, technology has barely progressed, and the earth is under harsh censorship and surveillance. Humanity has reverted to the Hitler days.

Don’t get depressed! Let’s build a mesh net!

In your manic mindset, you quickly throw together your portable phone re-charger, your Raspberry Pi Model B (YES I AM USING A MODEL B @Suser), and your Alfa AWUS036NH Network Card. You stuff it in a folder and admire your hardware 1337’ness. @Phoenix750.

“Sweet!” - You remark.

Don’t get too excited, it may look awesome but it doesn’t actually do anything yet…

You fire up dd and write that SD card with raspbian, then you boot up and SSH in. After the usual, and updates, you install the packages you will need.

sudo apt-get install isc-dhcp-server dnsmasq hostapd inspircd

First you check your network device is recognised

lsusb | grep 'Wireless'
>> Bus 001 Device 005: ID 148f:3070 Ralink Technology, Corp. RT2870/RT3070 Wireless Adapter


sudo nano /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet static


sudo nano /etc/hostapd/hostapd.conf



sudo nano /etc/dhcp/dhcp.conf

ddns-update-style none;

default-lease-time 600;
max-lease-time 7200;


log-facility local7;

subnet netmask {
 option broadcast-address;
 option routers;
 default-lease-time 600;
 max-lease-time 7200;
 option domain-name-servers;

Enable your services

sudo systemctl enable hostapd
sudo systemctl enable isc-dhcp-server
sudo systemctl enable dnsmsq

Do a cheeky reboot and then we can get to configuring the exciting things! If you check your wifi networks, there should be a network called 0x00sec protected by WPA2. Connect to it and hopefully you should get an IP. You will notice though that even if your PI is plugged in via ethernet, you aren’t getting any connection.

This is because you haven’t configured iptables to route your data, and you don’t have a DNS server! Remember how we installed dnsmasq earlier? Lets Configure that baby!


sudo nano /etc/dnsmasq.conf


sudo systemctl restart dnsmasq


Enable IP Forwarding

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

Now iptables routing

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

On your network now, you should get both an IP, and be able to access the internet on your device. But these rules won’t persist cross boot, so lets fix that.

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Now let’s open up that interfaces file again

sudo nano /etc/network/interfaces

and append this line

up iptables-restore < /etc/iptables.ipv4.nat

Cool, now we can configure IRC, or whatever else we want on the Pi, in my case I configured IRC and KiwiIRC. You can equally set up a tor proxy, or some sort of message board. The beauty of this is that it is completely offline, and you will instantly share any ethernet internet connection over wifi.

People can set up repeaters for this network, and this starts as a beautiful beginning for a mesh network. The other ideal part of this is that it is portable, you can take it anywhere, and allow people to connect. Now you have successfully thrawted the evil opressors, and saved humanity!

Personally I find this is very useful for hotels that only provide a single ethernet port. Heck, you could even connect a harddrive and install plexmediaserver on this baby. Portable Media Streamer! The possibilities are endless!

I hope this helped! FIGHT THE POWER.

Make sure to tell me what you thought about it, and what you would do or have done with a raspberry pi in the past? I am really interested to hear about your projects!

- pry0cc

The Hackers Lab - Rpi edition
(Not a N00b, but still learning) #2

Sweet article and nice storytelling! :smiley: In the case of your story, it would be interesting to do an ad-hoc network that doesn’t rely on one single router. Would be interesting how to do this…

(Command-Line Ninja) #3

Hm interesting. P2P WiFi? I’d like to know how that would work… Decentralized DHCP…

(Command-Line Ninja) #4

Perhaps you could develop a dhcp system that creates an address based off of a hash of the mac address. That way verification is trivial on all hosts. As for DNS it could operate exactly the same.

(Command-Line Ninja) #5

Straight outta superuser, It seems that a mesh network is what we would be looking at.

(Not a N00b, but still learning) #6

Yes, this is exactly what i meant. Somehow, I didn’t really manage to find a implementation of it. It would be a nice project, though very complex :slight_smile:

(Hardware Bias!) #7

10/10 just for the name “raspberry pry”


(Command-Line Ninja) #8

I wish I could take the credit. But I’m not a complete dick. It was 100% @_py’s suggestion for this write-up and the name. I just, you know, did the work :stuck_out_tongue:

(Command-Line Ninja) #9

This topic was automatically closed after 30 days. New replies are no longer allowed.