How to allow an ipsec tunnel endpoint to communicate with an internal IP on the other side?

This is a discussion on How to allow an ipsec tunnel endpoint to communicate with an internal IP on the other side? within the Linux Security forums, part of the System Security and Security Related category; Hi, My setup is like this: There are two sites. The internal network on one site is 192.168.0....


Go Back   Usenet Forums > System Security and Security Related > Linux Security

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-05-2005
kent@cpttm.org.mo
 
Posts: n/a
Default How to allow an ipsec tunnel endpoint to communicate with an internal IP on the other side?

Hi,

My setup is like this: There are two sites. The internal network on one
site
is 192.168.0.0/24 and the other side is 192.168.1.0/24. There is an
ipsec
server (let's call them r001 and r002 respectively) on each site
establishing
a VPN tunnel. Of course both r001 and r002 have a public IP. The VPN is
working
fine for the computers on the internal networks.

However, the question is, how to allow r001 itself connect to a host on

192.168.1.0/24 (eg, ping, ssh)? In most cases r001 will pick its public
IP
(because that interface is on the way to the default gateway). This
causes a
problem because a public IP can't connect to a private IP.

How to solve this problem? Thanks in advance!

Reply With Quote
  #2 (permalink)  
Old 07-05-2005
Joachim Schipper
 
Posts: n/a
Default Re: How to allow an ipsec tunnel endpoint to communicate with an internal IP on the other side?

kent@cpttm.org.mo wrote:
> Hi,
>
> My setup is like this: There are two sites. The internal network on one
> site
> is 192.168.0.0/24 and the other side is 192.168.1.0/24. There is an
> ipsec
> server (let's call them r001 and r002 respectively) on each site
> establishing
> a VPN tunnel. Of course both r001 and r002 have a public IP. The VPN is
> working
> fine for the computers on the internal networks.
>
> However, the question is, how to allow r001 itself connect to a host on
>
> 192.168.1.0/24 (eg, ping, ssh)? In most cases r001 will pick its public
> IP
> (because that interface is on the way to the default gateway). This
> causes a
> problem because a public IP can't connect to a private IP.
>
> How to solve this problem? Thanks in advance!


What's a VPN? The KAME port's IPSec (ipsec-tools+26sec)? OpenVPN?
OpenS/WAN+KLIPS? Some other combination?

If the VPN is working correctly, r001 should tunnel any traffic through
the VPN, on the public interface. I'm assuming the traffic is emitted,
but not moving through the VPN? Have you verified this? (Please note
that with at least the one VPN implementation I have used, a localhost
tcpdump will see stuff that isn't on the wire, because decrypted packets
are re-submitted to the network stack.)

Joachim
Reply With Quote
  #3 (permalink)  
Old 07-06-2005
Bryan Packer
 
Posts: n/a
Default Re: How to allow an ipsec tunnel endpoint to communicate with aninternal IP on the other side?

Joachim Schipper wrote:
> kent@cpttm.org.mo wrote:


>>In most cases r001 will pick its public IP
>>(because that interface is on the way to the default gateway). This
>>causes a
>>problem because a public IP can't connect to a private IP.
>>
>>How to solve this problem? Thanks in advance!

>
>
> What's a VPN? The KAME port's IPSec (ipsec-tools+26sec)? OpenVPN?
> OpenS/WAN+KLIPS? Some other combination?
>
> If the VPN is working correctly, r001 should tunnel any traffic through
> the VPN, on the public interface. I'm assuming the traffic is emitted,
> but not moving through the VPN? Have you verified this? (Please note
> that with at least the one VPN implementation I have used, a localhost
> tcpdump will see stuff that isn't on the wire, because decrypted packets
> are re-submitted to the network stack.)
>
> Joachim


If I remember what happens correctly, the FW knows to route packets down the tunnel correctly, but it uses the ip address of it's external interface since the traffic isn't being routed out the internal interface. The packet travels out the VPN tunnel, but since it's return address probably isn't part of the left_subnet (or whatever side it is), it doesn't route back correctly, or is blocked by firewall rules.

Add a rule to your iptables that tells the firewall to address its packets to the other lan using it's internal address rather than it's external one. Be very explicit in the packets you re-address this way, or you could end up messing up your regular outbound traffic.


iptables -t nat -A POSTROUTING -o ipsec0 -s $ext_ip -d $other_lan_subnet -j SNAT --to $int_ip

You may or may not need to add rules to actually allow this traffic depending on your config, but this should get you started.
bryan


--
If it isn't broke, fix it until it is.

Reply With Quote
  #4 (permalink)  
Old 07-06-2005
kent@cpttm.org.mo
 
Posts: n/a
Default Re: How to allow an ipsec tunnel endpoint to communicate with an internal IP on the other side?

Bryan Packer wrote:
> Add a rule to your iptables that tells the firewall to address its packets to
> the other lan using it's internal address rather than it's external one. Be
> very explicit in the packets you re-address this way, or you could end up
> messing up your regular outbound traffic.
>
>
> iptables -t nat -A POSTROUTING -o ipsec0 -s $ext_ip -d $other_lan_subnet -j
> SNAT --to $int_ip


Thanks. Does it mean that SNAT will be performed after ipsec tunneling?
So, the traffic is not encrypted?

Reply With Quote
  #5 (permalink)  
Old 07-06-2005
Bryan Packer
 
Posts: n/a
Default Re: How to allow an ipsec tunnel endpoint to communicate with aninternal IP on the other side?

kent@cpttm.org.mo wrote:
> Bryan Packer wrote:
>
>>Add a rule to your iptables that tells the firewall to address its packets to
>>the other lan using it's internal address rather than it's external one. Be
>>very explicit in the packets you re-address this way, or you could end up
>>messing up your regular outbound traffic.
>>
>>
>>iptables -t nat -A POSTROUTING -o ipsec0 -s $ext_ip -d $other_lan_subnet -j
>>SNAT --to $int_ip

>
>
> Thanks. Does it mean that SNAT will be performed after ipsec tunneling?
> So, the traffic is not encrypted?
>


Nope. The -o ipsec0 option only SNAT's packets leaving via the IPSec tunnel. The
encrypted packets that contain the SNAT'd packets would be leaving via eth1, and
won't be affected.

bryan

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:48 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0