LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-25-2009, 11:16 PM   #1
digger86
LQ Newbie
 
Registered: Jun 2009
Location: Oregon
Distribution: SLES, HPUX, SOLARIS
Posts: 24

Rep: Reputation: 0
iptables? masquerade?


forgive me I am new with Linux but I am trying to setup a OpenVPN server. I have the VPN working I can ping from both the client to server and server to client. What I would like to do is masq the tun0 adapter, from the not so detailed scraps I have found from google it seems possible?

What I am using is SLES 11 and currently routing openvpn.

I want the lan to see the already configured eth0 adapter. I am only ussing one physical adapter so what I would like to do is masq/loop the tun0 adapter.

clientt 10.6.1.1 --> server 10.8.1.1(eth0) --> vpn 10.4.0.6(tun0) --> LAN network 10.8.2.1

If I do not use the vpn and only ssh I can ssh to the server (eth0) and then ssh to the LAN network already so the routes work otherwise. I need this to work with VPN though.

Thansks
 
Old 06-26-2009, 03:19 AM   #2
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291

Rep: Reputation: 62
Ok I have not used a vpn before, but the normal way would be to do something like this hopefully when anything going out the vpn interface should have it's source changed to the address of the interface, and changed back when the packets of data return.

Quote:
iptables -t nat -A POSTROUTING -o tun0 -j SNAT --to 10.4.0.6
 
Old 06-26-2009, 08:56 AM   #3
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Are you aware of this?: http://iptables-tutorial.frozentux.n...-tutorial.html

It's a reference, perhaps the definitive reference, so it's long; but it might be helpful to you.
 
Old 06-26-2009, 12:46 PM   #4
digger86
LQ Newbie
 
Registered: Jun 2009
Location: Oregon
Distribution: SLES, HPUX, SOLARIS
Posts: 24

Original Poster
Rep: Reputation: 0
Thanks, this looks to be helpful.

Quote:
Quote:
iptables -t nat -A POSTROUTING -o tun0 -j SNAT --to 10.4.0.6
should it read?
Quote:
iptables -t nat -A POSTROUTING -o tun0 -j SNAT --to 10.8.1.1
since I want the the tun0 packets to look like they came from eth0, that is if I am reading the document correctly

I have tried both ways and I cannot get it to work still


here is a visual diagram
http://i298.photobucket.com/albums/m...gger86/VPN.gif
 
Old 06-26-2009, 01:33 PM   #5
digger86
LQ Newbie
 
Registered: Jun 2009
Location: Oregon
Distribution: SLES, HPUX, SOLARIS
Posts: 24

Original Poster
Rep: Reputation: 0
WOOT!! I got it!

I used:
Quote:
iptables -t nat -A POSTROUTING --source 10.4.0.0/24 -j SNAT --to 10.8.1.1
10.4.0.0/24 is the VPN's server address pool

Thanks again for your help.
 
Old 06-26-2009, 05:44 PM   #6
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291

Rep: Reputation: 62
Quote:
Originally Posted by digger86 View Post
WOOT!! I got it!

I used:


10.4.0.0/24 is the VPN's server address pool

Thanks again for your help.
Good to hear it's working, now I know what to do if I ever setup a vpn one day.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vpn masquerade with iptables fayax Linux - Networking 0 05-24-2007 04:12 PM
how iptables masquerade works sajjad81 Linux - Networking 1 03-15-2007 05:22 PM
iptables masquerade deconfliction ttucker Linux - Networking 15 08-01-2004 06:04 PM
iptables - true nat AND masquerade rebuke Linux - Security 3 11-11-2003 02:02 PM
Masquerade - iptables amphion Linux - Security 6 06-08-2003 09:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration