Raspberry Pi: Difference between revisions
(Created page with "The scope of this article is the installation steps taken to produce a local area network using a RaspberryPi 3, running Raspbian Jessy Lite, with a bridged internet connectio...") |
No edit summary |
||
Line 24: | Line 24: | ||
The file should contain, everything else can be commented out or deleted: | The file should contain, everything else can be commented out or deleted: | ||
<code> | <code>auto lo | ||
auto lo | |||
iface lo inet loopback | iface lo inet loopback | ||
Line 36: | Line 35: | ||
netmask 255.255.255.0 | netmask 255.255.255.0 | ||
network 10.1.1.0 | network 10.1.1.0 | ||
broadcast 10.1.1.255 | broadcast 10.1.1.255</code> | ||
</code> | |||
Install hostapd, and configure it. | Install hostapd, and configure it. | ||
Line 45: | Line 43: | ||
<code>$ sudo vi /etc/hostapd/hostapd.conf</code> | <code>$ sudo vi /etc/hostapd/hostapd.conf</code> | ||
<code> | <code>interface=wlan0 | ||
interface=wlan0 | |||
driver=nl80211 | driver=nl80211 | ||
ssid=Hackers & Designers | ssid=Hackers & Designers | ||
Line 55: | Line 52: | ||
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40] | ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40] | ||
macaddr_acl=0 | macaddr_acl=0 | ||
ignore_broadcast_ssid=0 | ignore_broadcast_ssid=0</code> | ||
</code> | |||
<code>$ sudo vi /etc/default/hostapd</code> | <code>$ sudo vi /etc/default/hostapd</code> | ||
Line 68: | Line 64: | ||
<code>$ sudo apt-get install dnsmasq</code> | <code>$ sudo apt-get install dnsmasq</code> | ||
<code> | <code>interface=wlan0 | ||
interface=wlan0 | |||
listen-address=10.1.1.1 | listen-address=10.1.1.1 | ||
bind-interfaces | bind-interfaces | ||
Line 75: | Line 70: | ||
domain-needed | domain-needed | ||
bogus-priv | bogus-priv | ||
dhcp-range=10.1.1.50,10.1.1.250,12h | dhcp-range=10.1.1.50,10.1.1.250,12h</code> | ||
</code> | |||
For the purposes of the Frankenstein "hovel" bot, also uncomment: | For the purposes of the Frankenstein "hovel" bot, also uncomment: | ||
<code> | <code>log-queries | ||
log-queries | log-dhcp</code> | ||
log-dhcp | |||
</code> | |||
Setup IPv4 forwarding. | Setup IPv4 forwarding. | ||
Line 95: | Line 87: | ||
Execute the following. | Execute the following. | ||
<code>$ | <code>$ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE</code> | ||
<code>$ sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT</code> | |||
<code>$ sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT</code> | |||
<code>$ sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"</code> | |||
To ensure the forwarding persists beyond restarts. | |||
<code>$ sudo vi /etc/rc.local</code> | |||
Add the following line before exit(0). | |||
<code>iptables-restore < /etc/iptables.ipv4.nat</code> | |||
Restart and verify the network is working. | |||
<code>$ sudo reboot</code> |
Revision as of 10:00, 14 July 2016
The scope of this article is the installation steps taken to produce a local area network using a RaspberryPi 3, running Raspbian Jessy Lite, with a bridged internet connection via an Ethernet cable to facilitate both the Hackers & Designers workshops around basic Unix and program skills for designers, and the Frankenstein Bot workshop by Constant.
Code blocks that begin with "$" denote terminal, command line instructions, all other code blocks denote configuration files and/or program source code.
In all locations where "vi" is used, feel free to use another text editor of your choice (ex. nano).
Setting up the network
These instructions are taken largely from here, but are reiterated in the case article disappears from the internet.
We need to tell dhcpcd to ignore the wlan0 interface.
$ sudo vi /etc/dhcpcd.conf
Add the following line to the bottom of the file:
denyinterfaces wlan0
wlan0 will need a static ip address.
$ sudo vi /etc/network/interfaces
The file should contain, everything else can be commented out or deleted:
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet static
address 10.1.1.1
netmask 255.255.255.0
network 10.1.1.0
broadcast 10.1.1.255
Install hostapd, and configure it.
$ sudo apt-get install hostapd
$ sudo vi /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
ssid=Hackers & Designers
hw_mode=g
channel=6
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
macaddr_acl=0
ignore_broadcast_ssid=0
$ sudo vi /etc/default/hostapd
Uncomment and set the following value:
DAEMON_CONF="/etc/hostapd/hostapd.conf
Install and configure dnsmasq.
$ sudo apt-get install dnsmasq
interface=wlan0
listen-address=10.1.1.1
bind-interfaces
server=8.8.8.8
domain-needed
bogus-priv
dhcp-range=10.1.1.50,10.1.1.250,12h
For the purposes of the Frankenstein "hovel" bot, also uncomment:
log-queries
log-dhcp
Setup IPv4 forwarding.
$ sudo vi /etc/sysctl.conf
Uncomment the following line.
net.ipv4.ip_forward=1
Execute the following.
$ 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
$ sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
To ensure the forwarding persists beyond restarts.
$ sudo vi /etc/rc.local
Add the following line before exit(0).
iptables-restore < /etc/iptables.ipv4.nat
Restart and verify the network is working.
$ sudo reboot