Skip to contentSkip to conversation

Problems after recompiling iptables 1.2.7 ..

DISCUSSION Raymond Leach 4 participants 4 messages Jan 20, 2003

lore
Share & tools
lore
#0 lore raw

Hi

I have a problem with NAT after recompiling iptables and my kernel.

This line gives an 'invalid argument' error:
iptables -t nat -A PREROUTING -i eth0 -s 192.168.0.0/24 -j SNAT --to-source 196.4.160.2

Is there something wrong with the above line, or is there something wrong with my kernel or iptables?

kernel version = 2.4.20 - 'Full Nat' is enabled
patch-o-matic 'time' patch applied
iptables version = 1.2.7

There were no errors during compile. Although, after rebooting the machine complains about a missing map file.

Regards

Ray

Signature · 19 lines
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(  Raymond Leach                       )
 ) Knowledge Factory                  (
(                                      )
 ) Tel: +27 11 445 8100               (
(  Fax: +27 11 445 8101                )
 )                                    (
(  http://www.knowledgefactory.co.za/  )
 ) http://www.saptg.co.za/            (
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   o                                o
    o                              o
        .--.                  .--.
       | o_o|                |o_o |
       | \_:|                |:_/ |
      / /   \\              //   \ \
     ( |     |)            (|     | )
     /`\_   _/'\          /'\_   _/`\
     \___)=(___/          \___)=(___/
#2 lore raw
In reply to Fabio Corneti
Quoted 23 lines · Fabio Corneti
Quoted 15 lines · Raymond Leach

Hi

I have a problem with NAT after recompiling iptables and my kernel.

This line gives an 'invalid argument' error:
iptables -t nat -A PREROUTING -i eth0 -s 192.168.0.0/24 -j SNAT --to-source 196.4.160.2

Is there something wrong with the above line, or is there something wrong with my kernel or iptables?

kernel version = 2.4.20 - 'Full Nat' is enabled
patch-o-matic 'time' patch applied
iptables version = 1.2.7

Quoted 6 lines

There were no errors during compile. Although, after rebooting the machine complains about a missing map file.

Regards

Ray

Quoted 12 lines

Shouldn't be specified an output interface/address with the -o option? Moreover, I think that if you want to do source nat, you should do it in the POSTROUTING chain. Try this (the existence of another network card eth1 is presumed):

iptables -t nat -A POSTROUTING -i eth0 -o eth1 -s 192.168.0.0/24 -j SNAT --to-source 196.4.160.2

Signature · 2 lines
Fabio Corneti
[email protected]

You are right.

SNAT MUST be done in the POSTROUTING chain.

Also, it MUST take an outgoing interface.

The incoming interface MAY BE specified if you have specific needs.

Ranjeet.

#1 lore raw
In reply to Raymond Leach
Quoted 15 lines · Raymond Leach

Hi

I have a problem with NAT after recompiling iptables and my kernel.

This line gives an 'invalid argument' error:
iptables -t nat -A PREROUTING -i eth0 -s 192.168.0.0/24 -j SNAT --to-source 196.4.160.2

Is there something wrong with the above line, or is there something wrong with my kernel or iptables?

kernel version = 2.4.20 - 'Full Nat' is enabled
patch-o-matic 'time' patch applied
iptables version = 1.2.7

Quoted 6 lines

There were no errors during compile. Although, after rebooting the machine complains about a missing map file.

Regards

Ray

Shouldn't be specified an output interface/address with the -o option? Moreover, I think that if you want to do source nat, you should do it in the POSTROUTING chain. Try this (the existence of another network card eth1 is presumed):

iptables -t nat -A POSTROUTING -i eth0 -o eth1 -s 192.168.0.0/24 -j SNAT --to-source 196.4.160.2

Signature · 2 lines
Fabio Corneti
[email protected]
#3 lore raw
In reply to Ranjeet Shetye
Quoted 13 lines · Ranjeet Shetye
Quoted 5 lines

Shouldn't be specified an output interface/address with the -o option? Moreover, I think that if you want to do source nat, you should do it in the POSTROUTING chain. Try this (the existence of another network card eth1 is presumed):

Quoted 7 lines

iptables -t nat -A POSTROUTING -i eth0 -o eth1 -s 192.168.0.0/24 -j SNAT --to-source 196.4.160.2

Signature · 2 lines
Fabio Corneti
[email protected]
Quoted 7 lines

You are right.

SNAT MUST be done in the POSTROUTING chain.

Also, it MUST take an outgoing interface.

The incoming interface MAY BE specified if you have specific needs.

This is incorrect.

It is correct that SNAT must be performed in the nat/POSTROUTING chain. but it is OPTIONAL to specify an outgoing interface. And you can NEVER specify an incoming interface in POSTROUTING.

Signature · 3 lines
/Martin

Never argue with an idiot. They drag you down to their level, then beat you with experience.