Ad-Hoc Networking

This document describes how to create an Ad-Hoc Networking between your mobile device and your host machine.

Setting up your mobile device

Inside Mamona insert the following lines into /etc/network/interfaces file:

auto wlan0
iface wlan0 inet static
       address 10.0.1.10
       netmask 255.255.255.0
       gateway 10.0.1.11
       network 10.0.1.0
       up iwconfig wlan0 essid ADHOCMAMONA key "s:0123456789abc" mode ad-hoc

Setting up your host machine

Here we are considering that your host machine is a debian like distribution, so we are going to
configure your host machine by editing its /etc/network/interfaces file:

Note: If you want your host machine configured as a gateway, go to the Gateway section.

auto eth1
iface eth1 inet static
     address 10.0.1.11
     netmask 255.255.255.0
     broadcast 10.0.1.255
     wireless_mode ad-hoc
     wireless_essid ADHOCMAMONA
     wireless_key "s:0123456789abc"
     up iptables -I INPUT 1 -s 10.0.1.10 -j ACCEPT

Now is time to start your wifi interface:

sudo ifup eth1

Testing

Let's test it:

ping 10.0.1.10

Another good option to test it is to install the ssh daemon and try to access remotely your mobile device.

Gateway

Insert the following lines in your /etc/network/interfaces file to have your host machine configured as a gateway:

iface eth1 inet static
     address 10.0.1.11
     netmask 255.255.255.0
     wireless_mode ad-hoc
     wireless_essid ADHOCMAMONA
     wireless_key "s:0123456789abc"
     up echo 1 > /proc/sys/net/ipv4/ip_forward
     up iptables -P FORWARD ACCEPT
     up iptables -A POSTROUTING -t nat -j MASQUERADE -s 10.0.1.0/24
     down echo 0 > /proc/sys/net/ipv4/ip_forward
     down iptables -t nat -F POSTROUTING