First you need to enable IP forwarding:
echo 1 > /proc/sys/net/ipv4/ip_forward
Then presuming that your VPN assigns a static IP you'll need SNAT:
iptables -t nat -A POSTROUTING -o <TUNNEL INTERFACE> -j SNAT --to-source <VPN IP>
replacing and as appropriate ofc. If your VPN gives you a dynamic IP, you'll need to use MASQUERADE instead:
iptables -t nat -A POSTROUTING -o <TUNNEL INTERFACE> -j MASQUERADE
Then check that your routing table is correct with:
route -n
check that you have a line similar to this:
0.0.0.0 <VPN ENDPOINT IP> 0.0.0.0 UG 2 0 0 <VPN INTERFACE>
if it's missing, add it:
route add default gw <VPN ENDPOINT IP> dev <VPN INTERFACE>
Each distro has it's own methods of making these changes permenant/persistant, so I'd need more info to help in that regards.
I am using a debian on a raspberry Pi.
I'm able to send packets as running tcpdump on ppp0 shows:
12:03:48.687991 IP rras-10-34-9-1.ncl.ac.uk.38988 > google-public-dns-b.google.com.domain: 10290+ A? accounts.google.com. (37) – Joe Simpson – 2013-10-03T12:05:19.690
Oh wait, I can access Google via ip address over the network now, but dns isn't working at all – Joe Simpson – 2013-10-03T12:26:35.797
You'll need to be more specific, DNS isn't working from where? What's the content of the pi's /etc/resolv.conf? the clients's /etc/resolv.conf? what's the pi's routing table? is /proc/sys/net/ipv4/ip_forward set to 1, etc etc – Nanzikambe – 2013-10-03T15:45:03.633
Yeah. I can access Google direct via ip address and dns works fine from the pi itself. Dns simply isn't working from a computer on the network – Joe Simpson – 2013-10-03T15:46:12.967
After doing a random test on changing DNS servers, it seemed by Uni VPN blocked any DNS that wasn't going to their DNS servers. Thanks anyway :) – Joe Simpson – 2013-10-04T19:32:42.337