Difference between revisions of "Ad-Hoc Network + Raspberry Pi"

From ESE205 Wiki
Jump to: navigation, search
(Created page with "<h1>Creating an Ad-Hoc Network</h1> An ad-hoc network can allow you to wirelessly communicate between multiple Raspberry Pis without the use of an external router. <h2>Step 1:...")
 
Line 13: Line 13:
 
<p>Modify (after saving a copy) <code>/etc/network/interfaces</code> to make it look like this</p>
 
<p>Modify (after saving a copy) <code>/etc/network/interfaces</code> to make it look like this</p>
 
  <nowiki>
 
  <nowiki>
iface eth0 inet static
+
iface wlan0 inet static
 
     address 192.168.1.2
 
     address 192.168.1.2
 
     netmask 255.255.255.0
 
     netmask 255.255.255.0
 
     gateway 192.168.1.1
 
     gateway 192.168.1.1
 
</nowiki>
 
</nowiki>
 +
<p>where address is the IP address you would like to give the Pi.</p>

Revision as of 16:05, 22 April 2018

Creating an Ad-Hoc Network

An ad-hoc network can allow you to wirelessly communicate between multiple Raspberry Pis without the use of an external router.

Step 1: Creating the Network

Ensure that the Pi can connect to WiFi. For the model 3+, this is built in. If your Pi is not a 3+, you will need a WiFi dongle.

Run the command

sudo iwconfig wlan0 mode ad-hoc channel 11 essid "mesh"

where "mesh" can be any name (it will be the name of the network).

You will now have to assign the Pi an IP address manually. To do this simply run

sudo ip addr add 192.168.1.34 dev wlan0

using an IP address of your choice.

If you want this network to be created and/or joined on startup, simply add these commands to /etc/rc.local

Step 2 (Optional): Giving the Raspberry Pi a static IP address

Modify (after saving a copy) /etc/network/interfaces to make it look like this

iface wlan0 inet static
    address 192.168.1.2
    netmask 255.255.255.0
    gateway 192.168.1.1

where address is the IP address you would like to give the Pi.