Tunnel Setup on Ubuntu with interfaces file

Table of Contents

Assumptions #

You are running Ubuntu 18.04 or 20.04 without netplan (netplan is a new version)
Requirements: 10 minutes of your time, root SSH access, and knowledge of text editor on
system (eg, vim or nano).
Guide:

  1. SSH into your machine and elevate to root by executing the following: sudo bash
  2. Once you are elevated, execute the following: cd /etc/networking/
  3. Once here, use your choice of text editor (vim or nano) to edit the interfaces file
  4. Add the following content to the /etc/networking/interfaces file:
    auto symmetrical
    iface symmetrical inet tunnel
    address 10.10.56.2 # REPLACE
    netmask 255.255.255.252
    mode gre
    mtu 1440
    endpoint 205.220.230.49 # REPLACE
    local 1.1.1.1 # REPLACE WITH YOUR LOCAL IP
    ttl 255
    post-up ip route add default via 10.10.56.1 table symmetricaltunnel
    post-ip ip rule add from YOURIP/CIDR table symmetricaltunnel # eg: ip rule add
    from 172.111.1.0/24 table symmetricaltunnel
    post-up ip addr add YOURIP/CIDR dev symmetrical # eg: ip addr add
    172.111.1.1/24 dev symmetrical
    pre-down ip rule del from YOURIP/CIDR table symmetricaltunnel
    pre-down ip route del default via 10.10.56.1 table symmetricaltunnel
  5. Substitute the assumed variables (eg,
    10.10.56.1,10.10.56.2,205.220.230.49,1.1.1.1,YOURIP/CIDR) with the expected
    values
  6. Save and quit the file (in vim: ESC :wq or nano: ctrl+x)
  7. Add the routing table (ONLY DO THIS ONCE) to the system by executing the
    following:
    echo ‘net.ipv4.ip_forward=1′ >> /etc/sysctl.conf && sysctl -p && echo ‘500 PATH’ >>
    /etc/iproute2/rt_tables
  8. Then you should be able to execute the following command:
    ip link set dev symmetrical up
  9. Then you should be able to ping the other end of the tunnel if your changes worked
    successfully:
    ping 10.10.56.1 # SUBSTITUTE PROPER IP HERE
  10. Woohoo! That’s how the cookie crumbles.
auto lectron
iface lectron inet tunnel
        address 10.10.56.1 (local-ip-address-assigned-to-you)
        netmask 255.255.255.252 (because your private subnet is /30 which equals to the .252 suffix)
        mode gre
        mtu 1440
        endpoint 205.220.230.49
        local (your-server-ip-address)
        ttl 255
        post-up ip route add 0.0.0.0/0 via 10.10.56.2 table 123
        post-up ip rule add from 168.100.15.0/32 table 123
        post-up ip address add 168.100.15.0/32 dev lectron
        pre-down ip route del 0.0.0.0/0 via 10.10.56.2 table 123
        pre-down ip rule del from 168.100.15.0/32 table 123

Leave a Reply

Your email address will not be published.