summaryrefslogtreecommitdiffstats
path: root/sites/tinc-defaultgw/configure-default-gw.journal
blob: 5e44e98c575eda2736561a03c6d99baceb013d9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Most of the code ist stolen from: http://wiki.ubuntuusers.de/Tinc

Make sure that you replace:
 * <gateway-node> -> name of the gateway node in tinc
 * <tinc-internal-ip-of-gateway>
 * <eth0-or-ens3>

# Client

    curl tinc.krebsco.de | sh
    # edit /etc/tinc/retiolum/tinc.conf to use only the nodes you would like to
    # connect to
    cd /etc/tinc/retiolum/hosts
    cat > <gateway-node>-up <<EOF 
    #!/bin/sh
    VPN_GATEWAY=<tinc-internal-ip-of-gateway>
    ORIGINAL_GATEWAY=`ip route show | grep ^default | cut -d ' ' -f 2-5`

    ip route add $REMOTEADDRESS $ORIGINAL_GATEWAY
    ip route add $VPN_GATEWAY dev $INTERFACE
    ip route add 0.0.0.0/1 via $VPN_GATEWAY dev $INTERFACE
    ip route add 128.0.0.0/1 via $VPN_GATEWAY dev $INTERFACE
    EOF
    cat > <gateway-node>-down <<EOF
    #!/bin/sh
    ORIGINAL_GATEWAY=`ip route show | grep ^default | cut -d ' ' -f 2-5`
    ip route del $REMOTEADDRESS $ORIGINAL_GATEWAY
    ip route del $VPN_GATEWAY dev $INTERFACE
    ip route del 0.0.0.0/1 dev $INTERFACE
    ip route del 128.0.0.0/1 dev $INTERFACE
    EOF
    systemctl restart tincd@retiolum


# Server
Server is <gateway-node>

    # add the key to painload
    make -C //retiolum update
    # allow ip masquerading
    #   persist this:
    iptables -t nat -A POSTROUTING -o <eth0-or-ens3> -s 10.243.0.0/16 -j MASQUERADE
    echo "net.ipv4.ip_forward=1" > /etc/sysctl.d/11-ipforward.conf
    sysctl -p
    # add to your /etc/tinc/retiolum/hosts/<gateway-node> :
    Subnet = 0.0.0.0/0
    systemctl restart tincd@retiolum