Scenario:
You have a local area network:

  • 192.168.1.1 – Router
  • 192.168.1.4 – Laptop
  • 192.168.1.5 – Desktop

Solution:
In this scenario, your desktop computer is connected to your corporate VPN. You would also like your laptop connected, but can’t because the VPN only allows 1 connection per username. Your corporate lan is a 10.0.0.0 network. In this example I use VPNC, which creates an interface called ‘tun0′ when I connect (use ifconfig -a to see all of your interfaces).

Commands on Desktop:

#!/bin/bash
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -i eth0 -d 10.0.0.0/8 -j ACCEPT
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
sysctl net.netfilter.nf_conntrack_acct=1

Commands on client:

#!/bin/bash
sudo route add -net 10.0.0.0 netmask 255.0.0.0 gw 192.168.1.5

Tags: , ,