Linux: IPRoute2

From RHS Wiki
Revision as of 08:38, 23 February 2018 by Rafahsolis (talk | contribs) (→‎Example)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Create tunnels[edit]

Steps[edit]

  1. Create a logical tunnel device
    ip tunnel add tun0 mode ipip local [host's A public ip] remote [remote host's B public ip]
  2. Assign an IP address to the device
    ip address add [private ip address] dev tun0
  3. Set up routing rules to route traffic over the tunnel
    ip route add [remote network]/24 via [remote tunnels IP address]
  • Each host is the mirror of the other when it comes to creating rules. E.G. The remote ip for host A is the local ip for host B and visa-versa.

Example[edit]

ip tunnel add tun0 mode ipip local 105.105.105.105 remote 41.41.41.41
ip address add 192.168.12.2 dev tun0
ip route add 10.0.10.0/24 via 192.168.12.2
ip route delete 192.168.1.0/24 dev eth0