Skip to contentSkip to conversation

Outgoing NAT problem.

DISCUSSION Carlos Cruells 2 participants 3 messages Jul 5, 2005

lore
Share & tools
lore
#0 lore raw

Regards from Madrid, Spain.

I am configuring a Iptables firewall on the office, but i have problems with the navigation from LAN to Internet. My configuration is the next:

- eth0 --> LAN Interface
- eth1 --> WAN Interface

I enter the next command:

iptables -t nat -A POSTROUTING -s 10.10.12.30 -o eth1 -j SNAT --to 62.93.44.116

The configuration results:

=====================================================
Chain PREROUTING (policy ACCEPT)
target prot opt source destination

Chain POSTROUTING (policy ACCEPT)

target     prot opt source               destination         
SNAT       all  --  10.10.12.30          anywhere            to:62.93.44.116 

=====================================================

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

=====================================================
IP_forward --> 1
=====================================================

All policies are in ACCEPT position, but it doesn't works. /proc/sys/net/ipv4/ip_forward = 1

When i do a simple ping test from LAN --> Internet, it fails, but if i repeat the same test from firewall, it does ok.

IP_LAN -------(ping)--------> IP www.cisco.com = Not OK Firewall -------(ping)--------> IP www.cisco.com = OK

Anybody can help me?

P.D: I know it. My english is not very good. :D

#1 lore raw
Quoted 2 lines · Carlos Cruells

iptables -t nat -A POSTROUTING -s 10.10.12.30 -o eth1 -j SNAT --to 62.93.44.116

If a packet has a source IP of 10.10.12.30 and is routed out the eth1 interface, rewrite the source IP to 62.93.44.116.

Quoted 1 line

When i do a simple ping test from LAN --> Internet, it fails, but if

Don't do it from anywhere on the LAN. Only do it from 10.10.12.30. It won't work from any other IP. Perhaps you wanted to use a different source specification, like "-s 10.10.12.0/24" or "-s 10.0.0.0/8"?

Quoted 4 lines

i repeat the same test from firewall, it does ok.

IP_LAN -------(ping)--------> IP www.cisco.com = Not OK Firewall -------(ping)--------> IP www.cisco.com = OK

DNS might also be a factor. Only the firewall machine and 10.10.12.30 would be able to get out to any external resolvers with that rule.

Signature · 2 lines
    mail to this address is discarded unless "/dev/rob0"
    or "not-spam" is in Subject: header
#2 lore raw

Yes, sorry, the source IP where i do my tests is "10.10.12.30" of course.

You wrote...

Quoted 2 lines

If a packet has a source IP of 10.10.12.30 and is routed out the eth1 interface, rewrite the source IP to 62.93.44.116.

...but it doesn't works and i don't know why. :(

It is correct, isn't it?--> iptables -t nat -A POSTROUTING -s 10.10.12.30 -o eth1 -j SNAT --to 62.93.44.116

Regards.

----- Original Message ----- From: "/dev/rob0" <[email protected]>
To: <[email protected]>
Sent: Tuesday, July 05, 2005 5:00 PM
Subject: Re: Outgoing NAT problem.

Quoted 25 lines · Carlos Cruells
Quoted 2 lines

iptables -t nat -A POSTROUTING -s 10.10.12.30 -o eth1 -j SNAT --to 62.93.44.116

If a packet has a source IP of 10.10.12.30 and is routed out the eth1 interface, rewrite the source IP to 62.93.44.116.

Quoted 1 line

When i do a simple ping test from LAN --> Internet, it fails, but if

Don't do it from anywhere on the LAN. Only do it from 10.10.12.30. It won't work from any other IP. Perhaps you wanted to use a different source specification, like "-s 10.10.12.0/24" or "-s 10.0.0.0/8"?

Quoted 4 lines

i repeat the same test from firewall, it does ok.

IP_LAN -------(ping)--------> IP www.cisco.com = Not OK Firewall -------(ping)--------> IP www.cisco.com = OK

DNS might also be a factor. Only the firewall machine and 10.10.12.30 would be able to get out to any external resolvers with that rule.

Signature · 2 lines
   mail to this address is discarded unless "/dev/rob0"
   or "not-spam" is in Subject: header