Linux Netfilter discussions
 help / color / mirror / Atom feed
* Routing through PtP and iptables
@ 2006-05-12 21:35 Antonio Di Bacco
  2006-05-12 23:56 ` Pascal Hambourg
  2006-05-13 10:38 ` Rob Sterenborg
  0 siblings, 2 replies; 4+ messages in thread
From: Antonio Di Bacco @ 2006-05-12 21:35 UTC (permalink / raw)
  To: netfilter

Hi all,

I have two identical linux boxes (A e B), each one with two interfaces: an 
ethernet (eth0 with ip 192.168.1.50) and an hdlc (hdlc0). The two boxes are 
only connected via a link through their hdlc interfaces. Because they have to 
be  exactly the same, if I have to assign an ip address to hdlc0 of A then 
the hdlc0 of B should have the same ip address. Each one should have a 
default route that cannot coincide with the hdlc interface. Every linux box 
has a web server. When I connect with my notebook to box A I want to reach 
the web server on A typing in my browser http://192.168.1.50 and I want to 
reach web server on B typing http://192.168.1.50:8080 .
Some one knows how could it be possible?

Thank you for your help,
Antonio.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Routing through PtP and iptables
  2006-05-12 21:35 Routing through PtP and iptables Antonio Di Bacco
@ 2006-05-12 23:56 ` Pascal Hambourg
  2006-05-13 10:38 ` Rob Sterenborg
  1 sibling, 0 replies; 4+ messages in thread
From: Pascal Hambourg @ 2006-05-12 23:56 UTC (permalink / raw)
  To: netfilter

Hello,

Antonio Di Bacco a écrit :
> 
> I have two identical linux boxes (A e B), each one with two interfaces: an 
> ethernet (eth0 with ip 192.168.1.50) and an hdlc (hdlc0). The two boxes are 
> only connected via a link through their hdlc interfaces. Because they have to 
> be  exactly the same, if I have to assign an ip address to hdlc0 of A then 
> the hdlc0 of B should have the same ip address. Each one should have a 
> default route that cannot coincide with the hdlc interface. Every linux box 
> has a web server. When I connect with my notebook to box A I want to reach 
> the web server on A typing in my browser http://192.168.1.50 and I want to 
> reach web server on B typing http://192.168.1.50:8080 .
> Some one knows how could it be possible?

I would choose a "fake" unused address $FAKE_IP, route it through the 
HDLC interface and NAT traffic on the HDLC link so that both source and 
destination addresses appear to be $FAKE_IP. Of course this address must 
not be assigned to any interface, else traffic to that address would be 
routed locally and that's not what you want.

Same setup on both boxes (not tested) :

# IP forwarding is assumed to be enabled by any means, e.g.
sysctl -w net.ipv4.ip_forward=1
# or
echo 1 > /proc/sys/net/ipv6/ip_forward

# add route to the fake address using 'route'
route add $FAKE_IP dev 'hdlc0'
# or using 'ip'
ip route add $FAKE_IP dev hdlc0

# forwarding box setup
# 1st step : NAT destination 192.168.1.50:8080 -> $FAKE_IP:80
iptables -t nat -A PREROUTING -d 192.168.1.50 -p tcp --dport 8080 \
   -j DNAT --to-destination $FAKE_IP:80

# 2nd step : NAT source on HDLC -> $FAKE_IP (for return path)
iptables -t nat -A POSTROUTING -o hdlc0 -d $FAKE_IP \
   -j SNAT --to-source $FAKE_IP

# server box setup
# NAT destination on HDLC $FAKE_IP -> 192.168.1.50
iptables -t nat -A PREROUTING -i hdlc0 -d $FAKE_IP \
   -j DNAT --to-destination 192.168.1.50


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Routing through PtP and iptables
  2006-05-12 21:35 Routing through PtP and iptables Antonio Di Bacco
  2006-05-12 23:56 ` Pascal Hambourg
@ 2006-05-13 10:38 ` Rob Sterenborg
  2006-05-13 12:41   ` antonio.dibacco
  1 sibling, 1 reply; 4+ messages in thread
From: Rob Sterenborg @ 2006-05-13 10:38 UTC (permalink / raw)
  To: netfilter

netfilter-bounces@lists.netfilter.org scribbled on :

> Hi all,
> 
> I have two identical linux boxes (A e B), each one with two
> interfaces: an ethernet (eth0 with ip 192.168.1.50) and an hdlc
> (hdlc0). The two boxes are only connected via a link through their
> hdlc interfaces. Because they have to be  exactly the same, if I have
> to assign an ip address to hdlc0 of A then the hdlc0 of B should have
> the same ip address. Each one should have a default route that cannot
> coincide with the hdlc interface. Every linux box has a web server.
> When I connect with my notebook to box A I want to reach the web
> server on A typing in my browser http://192.168.1.50 and I want to
> reach web server on B typing http://192.168.1.50:8080 . 
> Some one knows how could it be possible?
> 
> Thank you for your help,
> Antonio.

If Server A has IP 192.168.1.50, you *cannot* have a server B also on
192.168.1.50 in the samen LAN. You would have 1 IP address for multiple
servers and that just isn't going to work.

What you *can* do is :
Server A = 192.168.1.50
Server B = 192.168.1.51
Forward requests to 192.168.1.50:8080 to 192.168.1.51(:8080 or whatever
you like)


Gr,
Rob



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Routing through PtP and iptables
  2006-05-13 10:38 ` Rob Sterenborg
@ 2006-05-13 12:41   ` antonio.dibacco
  0 siblings, 0 replies; 4+ messages in thread
From: antonio.dibacco @ 2006-05-13 12:41 UTC (permalink / raw)
  To: Rob Sterenborg; +Cc: netfilter

[-- Attachment #1: Type: text/plain, Size: 1350 bytes --]

The two boxes will never be placed on the same LAN.

Thank you for your attention 

Rob Sterenborg Scrive: 

> netfilter-bounces@lists.netfilter.org scribbled on : 
> 
>> Hi all, 
>> 
>> I have two identical linux boxes (A e B), each one with two
>> interfaces: an ethernet (eth0 with ip 192.168.1.50) and an hdlc
>> (hdlc0). The two boxes are only connected via a link through their
>> hdlc interfaces. Because they have to be  exactly the same, if I have
>> to assign an ip address to hdlc0 of A then the hdlc0 of B should have
>> the same ip address. Each one should have a default route that cannot
>> coincide with the hdlc interface. Every linux box has a web server.
>> When I connect with my notebook to box A I want to reach the web
>> server on A typing in my browser http://192.168.1.50 and I want to
>> reach web server on B typing http://192.168.1.50:8080 . 
>> Some one knows how could it be possible? 
>> 
>> Thank you for your help,
>> Antonio.
> 
> If Server A has IP 192.168.1.50, you *cannot* have a server B also on
> 192.168.1.50 in the samen LAN. You would have 1 IP address for multiple
> servers and that just isn't going to work. 
> 
> What you *can* do is :
> Server A = 192.168.1.50
> Server B = 192.168.1.51
> Forward requests to 192.168.1.50:8080 to 192.168.1.51(:8080 or whatever
> you like) 
> 
> 
> Gr,
> Rob 
> 
> 
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-05-13 12:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-12 21:35 Routing through PtP and iptables Antonio Di Bacco
2006-05-12 23:56 ` Pascal Hambourg
2006-05-13 10:38 ` Rob Sterenborg
2006-05-13 12:41   ` antonio.dibacco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox