OpenVPN: push all LAN traffic through an OpenVPN client to the other side

  1. Local variables for this post, adjust to fit your setup:
    1. OpenVPN client server IP
      1. 192.168.1.200
    2. Remote network
      1. 172.16.1.0/24
  1. Add this to the client server that is using OpenVPN to connect to the remote server:
    1. sudo iptables -A POSTROUTING -o tun0 -j MASQUERADE
    2. as root user, do
      1. echo 1 > /proc/sys/net/ipv4/ip_forward
  2. Add this to your local computer 
    1. Linux: 
      1. ip route add 172.16.1.0/24 via 192.168.1.200
    2. Mac:
      1. route -n add 172.16.1.0/24 192.168.1.200
Now, you should be able to ping from your local computer, through the client machine, and to a server in the remote network. Once that works, try ssh.

NOTE: take a look at /etc/sysctl.conf if you want the ip_forward to last through reboots of client server: net.ipv4.ip_forward=1

Comments

Popular posts from this blog

Openvpn and unbound combined break dig command

Stress Linux system: stress-ng

Google Nexus 4: permanent back panel glass repair for less than a penny