Difference between revisions of "Mesh/Relay setup"

Jump to navigation Jump to search
5,689 bytes added ,  13:26, 8 February 2018
no edit summary
m
 
(11 intermediate revisions by one other user not shown)
Line 1: Line 1:
This page is outdated and is kept for our communal scrapbook. Please use https://github.com/sudomesh/exitnode for a more up-to-date info.
Relay nodes are Internet connected hosts that allow mesh nodes to talk to each other using batman-adv over the Internet. Mesh nodes connect to relay nodes using a type of layer 2 tunnel called [http://en.wikipedia.org/wiki/L2TP L2TP]. The software used to establish these tunnels is called [https://github.com/wlanslovenija/tunneldigger tunneldigger] and was developed by [https://dev.wlan-si.net/ wlan slovenija]. A relay node is usually a VPS or a dedicated server with a good amount of available bandwidth and cpu.  
Relay nodes are Internet connected hosts that allow mesh nodes to talk to each other using batman-adv over the Internet. Mesh nodes connect to relay nodes using a type of layer 2 tunnel called [http://en.wikipedia.org/wiki/L2TP L2TP]. The software used to establish these tunnels is called [https://github.com/wlanslovenija/tunneldigger tunneldigger] and was developed by [https://dev.wlan-si.net/ wlan slovenija]. A relay node is usually a VPS or a dedicated server with a good amount of available bandwidth and cpu.  


L2TP tunnels are unencrypted. They are used primarily because they are layer 2 (so they can be used for batman-adv) and are part of the Linux kernel. They code does not take up much space on the space-limited mesh nodes and does not use much cpu.
L2TP tunnels are unencrypted. They are used primarily because they are layer 2 (so they can be used for batman-adv) and are part of the Linux kernel. They code does not take up much space on the space-limited mesh nodes and does not use much cpu.


A relay node needs two pieces of software configured:
Configuring a relay node involves the following steps:
 
# B.A.T.M.A.N. Advanced
# Tunneldigger Broker


# Ensure that you have a compatible operating system
# Get a static IP assigned from sudo mesh (or use the test IP)
# Configure B.A.T.M.A.N. Advanced
# Configure Tunneldigger Broker


= Operating system =
= Operating system =
Line 75: Line 78:
== Other distros ==
== Other distros ==


You are on your own, but if you figure out how to get batman-adv and tunneldigger working on a different distro, then please edit this wiki!
You are on your own, but if you figure out how to get batman-adv and tunneldigger working on a different distro, then please edit this wiki.
 
= Getting an assigned static IP =
 
For testing purposes you can use the IP 10.42.254.254
 
If you want others to use your relay node, you should contact the sudo mesh group for a static IP assignment, either at info@sudomesh.org or by showing up to a weekly meeting or hacknight. Please include the following information:
 
*Relay node IP and port(s)
*Contact info for node administrator (at least an email address)
*How much bandwidth does the relay node provide? Is there a monthly limit?
 
In the future you will also have to agree to the terms of the Network Commons License, which has not yet been defined.


= batman-adv =
= batman-adv =
Line 92: Line 107:


  sudo aptitude install batctl
  sudo aptitude install batctl
Set a static IP for the bat0 interface by adding the following to /etc/network/interfaces:
iface bat0 inet static
    address 10.42.254.254
    netmask 255.0.0.0
If you have already received a static IP assignment from sudo mesh, then use that in place of 10.42.254.254.


= Tunneldigger broker =
= Tunneldigger broker =
Line 166: Line 189:
Open l2tp_broker.cfg.
Open l2tp_broker.cfg.


You will want to change the "address=" line to your public IP address, and "interface=" to your public ethernet interface.
You will want to change the "address=" line to your public IP address, and "interface=" to your public ethernet interface. E.g:
 
address=93.184.216.119
interface=eth0
 
You may also want to change the ports line. If you're running a DNS server on the same host then you'll want to remove port 53 from the list of ports.
 
Change the "session.up=" line to:
 
session.up=/opt/tunneldigger/broker/scripts/up_hook.sh
 
Now create the up_hook.sh file:
 
cd /opt/tunneldigger/broker/scripts
sudo touch up_hook.sh
sudo chmod 755 up_hook.sh
Edit up_hook.sh to contain the following:
 
<pre>
#!/bin/sh
 
INTERFACE="$3"
 
ifconfig $INTERFACE up
batctl if add $INTERFACE
 
if [ `cat /sys/class/net/bat0/operstate` != "up" ]; then
      ifconfig bat0 <relay_mesh_ip> netmask 255.0.0.0 up
fi
</pre>
 
Where <relay_mesh_ip> is your assigned mesh ip address (or 10.42.254.254 for testing).
 
Now you're ready to run the broker.


== Run the broker ==
== Run the broker ==
You can run the broker using:
sudo ./l2tp_broker.py l2tp_broker.cfg
To run the broker as a daemon and automatically on system startup, see the sections below.


== Test the broker ==
== Test the broker ==
To test the broker you need to install batman-adv and tunneldigger client on a different system. Ensure you have the L2TP modules installed and loaded on your client system. And ensure you have the batctl package installed and the batman_adv module loaded.
Install tunneldigger client requirements on you client system:
sudo aptitude install libnl-dev build-essential git
Download tunneldigger on client system:
cd
git clone https://github.com/wlanslovenija/tunneldigger.git
Compile tunneldigger client:
cd tunneldigger
make
Ensure that the tunneldigger broker is running on your relay node and run the tunneldigger client:
sudo ./l2tp_client -f -u foo -l <ip_of_your_relay_node>:<53> -i l2tp
The tunneldigger client should inform you when the tunnel has been established. This is what you'd expect to see:
l2tp-client: Performing broker selection...
l2tp-client: Selected 192.157.221.200:53 as the best broker.
l2tp-client: Tunnel successfully established.
If you use the -L option for l2tp_client, you may get an error from the broker like:
RTNETLINK answers: Invalid argument
Don't worry about it. The broker is attempting to clear out a sometimes non-existent traffic control rule using the command:
/sbin/tc qdisc del dev <tunnel_iface> root handle 1: htb default 0
This doesn't harm anything, but if you want to fix the behavior, look in traffic_control.py in the reset function.
After the tunnel is created, the interface l2tp0 should appear. Check with:
ifconfig l2tp0
Give it an IP in the 10.0.0.0/8 range, e.g:
sudo ifconfig l2tp0 10.254.254.254 netmask 255.0.0.0 up
Then add the tunnel interface to batman:
sudo batctl if add l2tp0
Now verify that batman is able to communicate over the tunnel:
batctl o
You should see output like:
[B.A.T.M.A.N. adv 2011.4.0, MainIF/MAC: l2tp1001/96:ea:1d:9a:e9:6c (bat0)]
  Originator      last-seen (#/255)          Nexthop [outgoingIF]:  Potential nexthops ...
06:15:6d:72:05:21    0.064s  (255) de:c9:2f:79:66:04 [  l2tp1001]: de:c9:2f:79:66:04 (255)
de:c9:2f:79:66:04    0.476s  (251) de:c9:2f:79:66:04 [  l2tp1001]: de:c9:2f:79:66:04 (251)
You may see only one entry in the list, but you should see at least one. You can run "batctl o" on the relay server as well and it should show one entry.
If you see at least one entry, that means you have layer 2 communication working between the client and server over the l2tp tunnel and that batman-adv is configured correctly.
Now check if layer 3 communication is also working. From the client:
ping 10.42.254.254
(or if you have are using an assigned static IP, ping that IP instead)
If you can ping, then everything is working correctly!


== Configure the broker to auto-start ==
== Configure the broker to auto-start ==
To configure the broker to start on boot, download the init script and place it in /etc/init.d:
cd
wget https://github.com/sudomesh/tunneldigger/raw/master/broker/scripts/tunneldigger-broker.init.d_alt
sudo mv tunneldigger-broker.init.d_alt /etc/init.d/tunneldigger
sudo chmod 755 /etc/init.d/tunneldigger
Edit the script to ensure that the BROKER_DIR is set to the directory where tunneldigger broker resides on your system.
Now configure the script to start and stop when your system boots up and shuts down:
sudo update-rc.d tunneldigger defaults
Reboot your system and verify that tunneldigger starts correctly.
= Securing your system =
Now that you're running a piece of the mesh infrastructure, you may want to ensure that your server stays reasonably secure. We recommend that you set up automatic security updates as described in [[Mesh/Server_security]] this guide.

Navigation menu