Skip to content

Commit 2f08f3c

Browse files
author
Ritwick DSouza
committed
[raspbian] Updates documentation
- Added docs on radio settings - Added docs on static routes
1 parent 0415c8d commit 2f08f3c

File tree

1 file changed

+173
-28
lines changed

1 file changed

+173
-28
lines changed

docs/source/backends/raspbian.rst

Lines changed: 173 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ The following *configuration dictionary*:
151151
{
152152
"general": {
153153
"hostname": "routerA",
154-
"timezone": "UTC",
155-
"ula_prefix": "fd8e:f40a:6701::/48"
154+
"timezone": "UTC"
156155
}
157156
}
158157
@@ -162,14 +161,18 @@ Will be rendered as follows::
162161

163162
routerA
164163

165-
run commands:
164+
# script: /scripts/general.sh
165+
166+
/etc/init.d/hostname.sh start
167+
echo "Hostname of device has been modified"
168+
timedatectl set-timezone UTC
169+
echo "Timezone has changed to UTC"
166170

167-
$ timedatectl set-timezone UTC
168171

169172
After modifying the config files run the following command to change the
170173
hostname::
171174

172-
$ /etc/init.d/hostname.sh start
175+
source scripts/general.sh
173176

174177
Network interfaces
175178
------------------
@@ -307,13 +310,13 @@ Will return the following UCI output::
307310

308311
auto eth0
309312
iface eth0 inet static
310-
address 192.168.1.1
311-
netmask 255.255.255.0
313+
address 192.168.1.1
314+
netmask 255.255.255.0
312315

313316
auto eth1
314317
iface eth1 inet dhcp
315318

316-
config: /etc/resolv.conf
319+
# config: /etc/resolv.conf
317320

318321
nameserver 10.11.12.13
319322
nameserver 8.8.8.8
@@ -402,10 +405,9 @@ Will be rendered as follows::
402405

403406
auto lan_bridge
404407
iface lan_bridge inet static
405-
address 172.17.0.2
406-
netmask 255.255.255.0
407-
bridge_ports eth0:0 eth0:1
408-
408+
address 172.17.0.2
409+
netmask 255.255.255.0
410+
bridge_ports eth0:0 eth0:1
409411

410412
Wireless Settings
411413
-----------------
@@ -484,23 +486,15 @@ following line::
484486

485487
#net.ipv4.ip_forward=1
486488

487-
This will enable on the next reboot. Incase you want to activate it immediately::
488-
489-
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
490-
491-
Let us assume we have internet connection on ``eth0``. We will need to configure
492-
a NAT between the ``wlan0`` and ``eth0`` interface. It can be done using the followin
493-
commands::
489+
After enabling IPv4 Forwarding in ``/etc/sysctl.conf`` you can run the bash script
490+
``/scripts/ipv4_forwarding.sh`` generated in your ``tar.gz`` file::
494491

495-
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
496-
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
497-
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
498-
499-
These rules need to be applied every time the Raspberry Pi is rebooted. Run ::
492+
source scripts/ipv4_forwarding.sh
500493

501-
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
502-
503-
Now open the `/etc/rc.local` file and just above the line ``exit 0``, add the following line::
494+
This will enable IPv4 forwarding, setup a NAT between your two interfaces and save the
495+
iptable in ``/etc/iptables.ipv4.nat``.
496+
These rules must be applied everytime the Raspberry Pi is booted up. To do so open the
497+
`/etc/rc.local` file and just above the line ``exit 0``, add the following line::
504498

505499
iptables-restore < /etc/iptables.ipv4.nat
506500

@@ -555,6 +549,19 @@ Will be rendered as follows::
555549
ieee80211n=1
556550
ssid=myWiFi
557551

552+
# config: /etc/network/interfaces
553+
554+
auto wlan0
555+
iface wlan0 inet manual
556+
557+
# script: /scripts/ipv4_forwarding.sh
558+
559+
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
560+
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
561+
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
562+
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
563+
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
564+
558565
Wireless AdHoc Mode
559566
~~~~~~~~~~~~~~~~~~~
560567

@@ -591,7 +598,6 @@ Will result in::
591598
wireless-essid freifunk
592599
wireless-mode ad-hoc
593600

594-
595601
WPA2 Personal (Pre-Shared Key)
596602
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
597603

@@ -646,6 +652,145 @@ Will be rendered as follows::
646652
wpa_passphrase=passphrase012345
647653
wpa_pairwise=TKIP CCMP
648654

655+
# config: /etc/network/interfaces
656+
657+
auto wlan0
658+
iface wlan0 inet manual
659+
660+
# script: /scripts/ipv4_forwarding.sh
661+
662+
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
663+
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
664+
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
665+
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
666+
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
667+
668+
Radio settings
669+
--------------
670+
671+
The radio settings reside in the ``radio`` key of the *configuration dictionary*,
672+
which must contain a list of `NetJSON radio objects <http://netjson.org/rfc.html#radios1>`_
673+
(see the link for the detailed specification).
674+
675+
Radio object extensions
676+
~~~~~~~~~~~~~~~~~~~~~~~
677+
678+
In addition to the default *NetJSON Radio object options*, the ``OpenWrt`` backend
679+
also requires setting the following additional options for each radio in the list:
680+
681+
+--------------+---------+-----------------------------------------------+
682+
| key name | type | allowed values |
683+
+==============+=========+===============================================+
684+
| ``protocol`` | string | 802.11a, 802.11b, 802.11g, 802.11n, 802.11ac |
685+
+--------------+---------+-----------------------------------------------+
686+
687+
Radio example
688+
~~~~~~~~~~~~~
689+
690+
The following *configuration dictionary*:
691+
692+
.. code-block:: python
693+
694+
{
695+
"radios": [
696+
{
697+
"name": "radio0",
698+
"phy": "phy0",
699+
"driver": "mac80211",
700+
"protocol": "802.11n",
701+
"channel": 11,
702+
"channel_width": 20,
703+
"tx_power": 5,
704+
"country": "IT"
705+
},
706+
{
707+
"name": "radio1",
708+
"phy": "phy1",
709+
"driver": "mac80211",
710+
"protocol": "802.11n",
711+
"channel": 36,
712+
"channel_width": 20,
713+
"tx_power": 4,
714+
"country": "IT"
715+
}
716+
],
717+
"interfaces": [
718+
{
719+
"name": "wlan0",
720+
"type": "wireless",
721+
"wireless": {
722+
"radio": "radio0",
723+
"mode": "access_point",
724+
"ssid": "myWiFi"
725+
}
726+
}
727+
]
728+
}
729+
730+
Will be rendered as follows::
731+
732+
# config: /etc/hostapd/hostapd.conf
733+
734+
interface=wlan0
735+
driver=nl80211
736+
hw_mode=g
737+
channel=11
738+
ieee80211n=1
739+
ssid=myWiFi
740+
741+
# config: /etc/network/interfaces
742+
743+
auto wlan0
744+
iface wlan0 inet manual
745+
746+
# script: /scripts/ipv4_forwarding.sh
747+
748+
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
749+
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
750+
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
751+
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
752+
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
753+
754+
Static Routes
755+
-------------
756+
757+
The static routes settings reside in the ``routes`` key of the *configuration dictionary*,
758+
which must contain a list of `NetJSON Static Route objects <http://netjson.org/rfc.html#routes1>`_
759+
(see the link for the detailed specification).
760+
The following *configuration dictionary*:
761+
762+
763+
Static route example
764+
~~~~~~~~~~~~~~~~~~~~
765+
766+
.. code-block:: python
767+
768+
{
769+
"interfaces": [
770+
{
771+
"name": "eth0",
772+
"type": "ethernet"
773+
}
774+
],
775+
"routes": [
776+
{
777+
"device": "eth0",
778+
"destination": "192.168.4.1/24",
779+
"next": "192.168.2.2",
780+
"cost": 2,
781+
},
782+
]
783+
}
784+
785+
Will be rendered as follows::
786+
787+
# config: /etc/network/interfaces
788+
789+
auto eth0
790+
iface eth0 inet manual
791+
post-up route add -net 192.168.4.1 netmask 255.255.255.0 gw 192.168.2.2
792+
pre-up route del -net 192.168.4.1 netmask 255.255.255.0 gw 192.168.2.2
793+
649794
NTP settings
650795
------------
651796

0 commit comments

Comments
 (0)