Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to setup my own little access point and I've got two core elements of it working.

  1. The WiFi Access point is connectible. I can access a webserver on the router
  2. SSH-ing into the router, I can connect to the outside internet via PPTP

Does anyone know of any way I can connect the two elements together?

share|improve this question

1 Answer 1

up vote 1 down vote accepted
+50

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.

share|improve this answer
    
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 Oct 3 '13 at 12:05
    
Oh wait, I can access Google via ip address over the network now, but dns isn't working at all –  Joe Simpson Oct 3 '13 at 12:26
    
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 Oct 3 '13 at 15:45
    
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 Oct 3 '13 at 15:46
    
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 Oct 4 '13 at 19:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.