Skip to contentSkip to conversation

How to loop back internal traffic?

DISCUSSION Jorge Canas 3 participants 4 messages Feb 10, 2007

lore
Share & tools
lore
#0 lore raw

Hi,

I have a machine configured as my gateway: nat, fw & dhcp server for other machines inside my local network. The gw machine has a public IP (assigned via DHCP from ISP) and a public domain name (updated through ddns).

I have one of my other internal machines running a webserver. The gw just does port forwarding of external traffic (destined for port 80) to this other internal machine.

How do I configure the firewall rules on the gw so that the port forwarding also occurs when my other local network machines try to go to the website via the public domain name?

Thanks.

_________________________________________________________________
Invite your Hotmail contacts to join your friends list with Windows Live Spaces http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us

#1 lore raw

Hi,
try this
iptables -t nat -A PREROUTING -p tcp --dport 80 -i ppp0 (or how you call it ) -j DNAT --to-destination ip_address_of_server_in_internal_network

Regards

Quoted 15 lines · --- Jorge Canas

Hi,

I have a machine configured as my gateway: nat, fw & dhcp server for other
machines inside my local network. The gw machine has a public IP (assigned
via DHCP from ISP) and a public domain name (updated through ddns).

I have one of my other internal machines running a webserver. The gw just
does port forwarding of external traffic (destined for port 80) to this
other internal machine.

Quoted 9 lines

How do I configure the firewall rules on the gw so that the port forwarding
also occurs when my other local network machines try to go to the website
via the public domain name?

Thanks.

_________________________________________________________________

Quoted 4 lines

Invite your Hotmail contacts to join your friends
list with Windows Live
Spaces

http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us

Quoted 3 lines

____________________________________________________________________________________
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html

#2 lore raw
In reply to Jorge Canas
Quoted 3 lines · Jorge Canas

How do I configure the firewall rules on the gw so that the port forwarding also occurs when my other local network machines try to go to the website via the public domain name?

You have to extend your SNAT rule so thoses machines egts NATed when trying to reach this webserver using its public IP, otherwise, you'll get a triangle situation where your webserver sends its SYN/ACK directly through the LAN with its private IP.

Something like:

	iptables -t nat -A POSTROUTING -s $LAN -d $WebServPrivIP \
		-j SNAT --to-source $GWPrivIP

BTW, it's a FAQ, but I agree it might be difficult to find relevant answers in the wild.

Signature · 2 lines
http://sid.rstack.org/
PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
Quoted 2 lines
Quoted 2 lines

Hi! I'm your friendly neighbourhood signature virus. Copy me to your signature file and help me spread!

#3 lore raw
Quoted 15 lines

From: Cedric Blancher <[email protected]>
To: Jorge Canas <[email protected]>

Quoted 1 line · Jorge Canas

How do I configure the firewall rules on the gw so that the port

forwarding

Quoted 1 line

also occurs when my other local network machines try to go to the

website

Quoted 1 line

via the public domain name?

You have to extend your SNAT rule so thoses machines egts NATed when trying to reach this webserver using its public IP, otherwise, you'll get a triangle situation where your webserver sends its SYN/ACK directly through the LAN with its private IP.

Quoted 8 lines

Something like:

	iptables -t nat -A POSTROUTING -s $LAN -d $WebServPrivIP \
		-j SNAT --to-source $GWPrivIP

BTW, it's a FAQ, but I agree it might be difficult to find relevant answers in the wild.

Thanks for the reply Cedric. I tried the rule but it did not work. I got a connection refused message. This is the rule I added:

iptables -A POSTROUTING -s 192.168.123.0/24 -d 192.168.123.164 -j SNAT --to-source 192.168.123.161 -t nat

My internal webserver is running at 192.168.123.164 The internal interface of the GW is 192.168.123.161

_________________________________________________________________
Don’t miss your chance to WIN 10 hours of private jet travel from Microsoft Office Live http://clk.atdmt.com/MRT/go/mcrssaub0540002499mrt/direct/01/