Home > Documentation > intermediate

Janmesh - Linux Documentation

Make sure you read beginner documentation to know what we'll talk about here.

Intermediate tutorial n°1: Share the internet connexion with a computer that is only connected to Janmesh


Voodoo computing warning The author of this tutorial achieved to make things work but does not fully understand how or why. Use at your own risk.
Basics
We got two Janmesh nodes, connected together through CoOoOw mesh-local wifi. Both got the /etc/init.d/janmesh script installled. If you're not sure to know what this mean, please refer to the beginner's tutorials.
One station is the "client", whishing to have internet access. The other station has internet access through Ethernet (eth0) and whishes to share this access with the client.
The first thing to edit is the two /etc/cjdroute.conf files on each computer.

$ sudo nano /etc/cjdroute.conf
Locate in this file the "publicKey" for each one. We'll need them.

On the gateway, look at the output of the
ifconfig
command and take note of the "adr inet6" given for the "eth0" interface.
We want the adress of the form 111:1111:1111:1111:1111:1111 and NOT the "/64" or whatever mask (number) is used.
then on the gateway, give credential to the client, by editing gateway's cjdroute.conf this way:
in the section "router > iptunnel > allowedConnection" edit the section this way
//  It's ok to only specify one address.
                 {      //anduril access
                     "publicKey": "herepastethePublicKeyoftheclient.k",
                     "ip6Address": "1111:1111:1111:1111:1111:1111:1111",
                     "ip6Prefix": 0,
                     "ip4Address": "10.0.0.4",
                     "ip4Prefix": 0
                 }

As you can see, you have to edit "publicKey" and "ip6Address" with the numbers that you were asked to keep at hand previously.
Then on the client, indicate that we want to link with the gateway:
in the section "router > iptunnel > outgoingConnections", on a new line, add the following:
"herepastethePublicKeyofthegateway.k"
With the public key of the gateway that you got previously.
Then we gonna edit the /etc/init.d/janmesh startup scripts on both machines to set the correct routing and adresses upon start of the Janmesh service.
1111:1111:1111:1111:1111:1111:1111 still refer to the adress you took note of previously.
On the gateway:
#!/bin/sh
case $1 in 
         start)
                /usr/bin/nmcli con up id janmesh;
                /usr/bin/cjdroute < /etc/cjdroute.conf;
                /usr/sbin/olsrd;
                ip -6 addr ad dev tun0 1111:1111:1111:1111:1111:1111/64
                ip addr add dev tun0 10.0.0.1/24;
                ip route add 10.0.0.0/24 dev tun0;
                ip -6 route add dev eth0 1111:1111:1111:1111:1111:1111:1;
                ip -6 route add dev tun0 1111:1111:1111:1111:1111:1111/64;
                ip -6 route add default via 1111:1111:1111:1111:1111:1111;
                iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;
                iptables -A FORWARD -i eth0 -o tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT;
                iptables -A FORWARD -i tun0 -o eth0 -j ACCEPT;;

         stop)
                /usr/bin/killall cjdroute;
                /usr/bin/killall olsrd;;
		/usr/bin/nmcli conn down janmesh;;
esac
NOTE THE TRAILING ":1" on the line ip -6 route add dev eth0 1111:1111:1111:1111:1111:1111:1;
And on the client:
#!/bin/sh
case $1 in 
         start)
                /usr/bin/nmcli con up id janmesh;
                /usr/bin/cjdroute < /etc/cjdroute.conf;
                /usr/sbin/olsrd;
                sleep 25;
                ip route add 10.0.0.0/24 via 10.0.0.4;
                ip route add default via 10.0.0.4;;
         stop)
                /usr/bin/killall cjdroute;
                /usr/bin/killall olsrd;
		/usr/bin/nmcli conn down janmesh;
esac

DNS configuration

You'll have to know the IPv4 adress of your home modem/router (box provided by your ISP), which could be, say, 192.168.1.1, 192.168.1.254, or whatever ! Good luck (or alternatively you can make use of any other online public DNS server's IP address). Indicate it by editing
/etc/resolvconf/resolv.conf.d/tail
this way:
nameserver 192.168.1.254
replace the dot-separated numbers with the actual address of your internet box.

You're done. Once Janmesh service relaunched on both computing devices, you should be able to ping google.com or whatever from the client, starting from now.
The "sleep 25" seems mandatory, since adresses not associate instantly when the network is brought up. If you got an error message when running /etc/init.d/janmesh starton the client, wait for one second or two and retry, generally it's enough.
Licensing: this tutorial is placed under two licenses. Code is placed under AGPLv3 license. Other text content here is licensed under Creative Commons BY-SA 4.0 license. Authors are : Shangri-l