Raspberry Pry - Offline Communications Network

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 through 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. @anon79434934.

“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

Interfaces

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
  address 10.0.1.2
  netmask 255.255.255.0

Hostapd

sudo nano /etc/hostapd/hostapd.conf

interface=wlan0
ssid=0x00sec
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=0x00secIsBae
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

DHCP

sudo nano /etc/dhcp/dhcp.conf

ddns-update-style none;

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

authoritative;

log-facility local7;

subnet 10.0.1.0 netmask 255.255.255.0 {
 range 10.0.1.10 10.0.1.254;
 option broadcast-address 10.0.1.255;
 option routers 10.0.1.2;
 default-lease-time 600;
 max-lease-time 7200;
 option domain-name-servers 10.0.1.2;
}

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!

Dnsmasq

sudo nano /etc/dnsmasq.conf

domain-needed
interface=wlan0
no-dhcp-interface=wlan0

sudo systemctl restart dnsmasq

Routing

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

11 Likes

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…
SmartOne

1 Like

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

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.

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

1 Like

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:

1 Like

10/10 just for the name “raspberry pry”

-Phoenix750

2 Likes

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:

3 Likes

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