Port forward into VPN tunel

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
Csali
DD-WRT Novice


Joined: 16 Aug 2010
Posts: 3

PostPosted: Mon Aug 16, 2010 11:37    Post subject: Port forward into VPN tunel Reply with quote
Hi,

I have 2 sites (Site A and B) with ddwrt routers. On the second site (Site B) the ISP gives only a NAT-ted internet access, so port forward on the router is not working. As a workaround I want to crate a VPN between the sites (routed openvpn) . The ISP on Site A gives a proper public IP address, and port forward is working into Site A's local subnet.

Is it possible to create a port forward rule on Site A's router to forward incoming packets on port XXX trough the VPN tunel to an IP in Site B????

Thanks in advance!

Steve
Sponsor
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Tue Aug 17, 2010 7:34    Post subject: Reply with quote
Yes it's possible as long as you set up your tunnel and routing correctly. The key thing is that the tunnel will have to be NAT'd (I think it is by default if done through the GUI) so that router B will return the responses through the tunnel instead of trying to route out its own WAN with the wrong source IP.
_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
Csali
DD-WRT Novice


Joined: 16 Aug 2010
Posts: 3

PostPosted: Wed Aug 18, 2010 7:28    Post subject: Reply with quote
Thnaks for pointing me into direction.

After implementig VPN based on gui instructions I had to add

iptables -I FORWARD -i br0 -o tun0 -j ACCEPT
iptables -I FORWARD -i tun0 -o br0 -j ACCEPT

to the firewall script on site B (Client site with no true public IP)

Now clients from Site A and Site B can reach each other from both Sites.

On the router on Site A I created a port forward rule to the IP on Site B, but it is not working from the internet. The problem seems to be that you mention, that the router on site B send the reply packets to the internet and not into the tunel.

How could I tell the router to send the reply messeage for the packets that came trough the tunnel back via the tunel??
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Wed Aug 18, 2010 8:22    Post subject: Reply with quote
Add this to your firewall script on router A to do NAT for any traffic going through the tunnel.

iptables -t nat -I POSTROUTING -o tun0 -j MASQUERADE

_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
Csali
DD-WRT Novice


Joined: 16 Aug 2010
Posts: 3

PostPosted: Thu Aug 19, 2010 7:04    Post subject: Reply with quote
Thanks, its working perfectly!
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum