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 11-05-2008, 07:31 PM   #1
ThanhDuongCong
LQ Newbie
 
Registered: Nov 2008
Posts: 27

Rep: Reputation: 15
Problem between OPENSWAN vs IPTABLES


Hi everybody ,
I've been configured OPENSWAN between 2 offices , it's working fine and I can access resource between these sites .But now one of my office need to acces the internet through CENTOS , I'd like to additional configure NAT Static for my network to access the internet (I've static IP 222.255.239.18) but while I configure SNAT then I can not communicate my offices each other (my command to nat : iptables -t nat -A POSTROUTING -s 172.16.0.0/23 -j SNAT --to 222.255.239.18 . So I have to DEL that rule .If anybody used to meet this issue , pls try to help me . Because it's really very urgent
Thank you very much indeed .
 
Old 11-06-2008, 12:43 PM   #2
rossonieri#1
Member
 
Registered: Jun 2007
Posts: 359

Rep: Reputation: 34
never mind ... sorry

Last edited by rossonieri#1; 11-06-2008 at 01:05 PM.
 
Old 11-06-2008, 12:49 PM   #3
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
Have you tried using a MASQUERADE rule, something like:

iptables -t nat -A POSTROUTING -s 172.16.0.0/23 -o <ethernet_device> -j MASQUERADE

where ethernet device is the one configured with your 222.255.239.18
 
Old 11-06-2008, 01:04 PM   #4
rossonieri#1
Member
 
Registered: Jun 2007
Posts: 359

Rep: Reputation: 34
ouch,

i did not read it carefully -
the OP was asking about internet sharing and 2 links.

actually - how many links do you have thanh? 1 link to remote office, or 2?
 
Old 11-06-2008, 08:49 PM   #5
ThanhDuongCong
LQ Newbie
 
Registered: Nov 2008
Posts: 27

Original Poster
Rep: Reputation: 15
Thank you for your help ,
To estabroo : I tried to use iptables -t nat -A POSTROUTING -s 172.16.0.0/23 -o <ethernet_device> -j MASQUERADE but it was same iptables -t nat -A POSTROUTING -s 172.16.0.0/23 -j SNAT --to 222.255.239.18

To rossonieri#1 :
Let me tell you more detail : I configured my network with single AD on 2 sites and at each site I have firewall (Centos 5.0) that means I have 2 firewall at each site ,and they were configured VPN by OPENSWAN .Until now , it's working fine .But I'd like to use iptables to configure more for my users can be accessed internet through my firewall with one public IP ,when my firewall was configured that rule then the connection of VPN drop immediately .So I need your help to assist me how to run OPENSWAN and IPTABLES on the same firewall machine

Best regards,
 
Old 11-06-2008, 11:53 PM   #6
rossonieri#1
Member
 
Registered: Jun 2007
Posts: 359

Rep: Reputation: 34
hi thanh,

thats what i thought in the first place - hmm ... why did i erase my first post

since you are now running a ipsec PTP to remote-site - you have to build once again your iptables from scratch - because your main target now is to share your 1 internet connection using MASQ or SNAT - then the second job is to allow ipsec pass-thru the firewall to remote site.

ipsec-related ports/protocol : UDP 4500 (ipsec NAT-T), UDP 500 (IKE), IP 50 (ESP) IP 51 (AH).
those 4 need to be open to both direction - i think you already understand which ports to open right since you already did make it work?

reference : http://lartc.org/howto/lartc.ipsec.tunnel.html

HTH.
 
Old 11-07-2008, 12:46 AM   #7
ThanhDuongCong
LQ Newbie
 
Registered: Nov 2008
Posts: 27

Original Poster
Rep: Reputation: 15
Firstly :
Yes I know , I realize about you mentioned about those ports , in fact I have 8 WAN IPs on that firewall machine that configured by alias(that's mean I configured another IP for VPN) . The problem is when firewall was configured rules for my users access the internet through firewall machine by iptables then VPN dropped imediately (although VPN didn't drop before I was adding iptables rules and now it's working fine).
The second point I'd like to ask you how to configure OPENSWAN by using dynamic WAN IP because in Viet Nam there are many locations have dynamic WAN IP)

Let me post my ipsec.conf for you to consider it

# basic configuration
config setup
# Debug-logging controls: "none" for (almost) none, "all" for lots.
# klipsdebug=all
# plutodebug=dns


# Add connections here.

# sample VPN connection
conn net-to-net
# Left security gateway, subnet behind it, next hop toward right.
left=210.245.112.212
leftsubnet=172.16.0.0/23
leftrsasigkey=0sAQN4gj04X4Bf6BXRrodbhfeoe6e3OiSFcLBDkg8OhpUbKTnFMfidz30v49hL0L36ELJNg7FL3n6spPCUzlF9 1c8BSyZ/qEE5xQvAMwyCwLCD0ppfwcUvhWXPSzu8S4GQMtc0zMX83a04vxGCbBLyU9E6nanl05YfjIbN0UgT//mgGqxdJBTkKu1pHwRpvvqcyVCIYMCAmTm0dOCbnB6hzkoe9VJn1MxWByzwi4NId5xjSzn9uKni1lVjC57nWnl4qpWn1fJTZN/WVgaWwtV0DxSj1/+kq8kmz1IEVUTVPUDJNWpVOTEgGI6j7HogaJwwU/Ck72PBtmcBkC4Ck2huZL7lPR0wWqGgN1v7FfMh5tdxbQRl
leftnexthop=210.245.112.209
# Right security gateway, subnet behind it, next hop toward left.
right=222.255.237.61
rightsubnet=192.168.104.0/24 rightrsasigkey=0sAQNYokeJYiaTWfLQijVnP9TdAm9mo7IxeyumDupgoUnXmb889Evt+6aA9jj6pILmBptK3vAZhotArQGjbFZ ydCmNkPuavobWfHX64hdr0GJg+hLRPIAzEad1TVVTwA7r7z0GZziLYgaCyx/rU4jonIuvYFisiT1pZv5z5OAQzjup2ZdONI69pm4IsiPEsjJ8BxZfElz9flJvjNOkZCrpbAMgFLuvU6d5gVVSzUvPk+6SEV0x9Ie oX56K3C38kzYmZilV4cDdLzxR7byH2uZRKeVlc1AhGNr7aLkSJgmDAtXg4602K5iHWx0ICGUFRSpruoREMqPb117tZmkD5G5j0Aw 6EaAw+9577E+o8cDFLvk5KGUl
rightnexthop=222.255.237.254
# To authorize this connection, but not actually start it, at startup,
# uncomment this.
auto=start

#Disable Opportunistic Encryption
include /etc/ipsec.d/examples/no_oe.conf

my rules pass-thru by iptables :
VPNLeft :


iptables -t nat -A POSTROUTING -o eth0 -s 172.16.0.0/23 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -s 172.16.0.0/23 -d \! 192.168.104.0/24 -j MASQUERADE

VPNRight :


iptables -t nat -A POSTROUTING -o eth0 -s 192.168.104.0/24 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.104.0/24 -d \! 172.16.0.0/23 -j MASQUERADE



I'm very appcreciate about your help

Last edited by ThanhDuongCong; 11-07-2008 at 12:51 AM.
 
  


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
CentOS 5.1 with Openswan 2.6 problem aikie Linux - Networking 1 08-05-2008 01:38 AM
Problem:VPN wireless connection with OpenSwan on Slackware 12.0 Salgeras Linux - Wireless Networking 2 10-05-2007 02:46 AM
OpenSWAN and IPTables the_jaymz Linux - Networking 2 03-06-2007 03:16 AM
problem installing openswan Baracuda Linux - Security 1 11-24-2005 04:46 PM
Openswan: STATE_QUICK_I1: initiate (NAT Problem?) havelino Linux - Networking 0 11-03-2005 11:04 AM

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

All times are GMT -5. The time now is 02:18 AM.

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