iptables: can't set any ip address in rules
Hello all,
I am not able to set any rule that contsin ip address in the iptables.
For example I give this command
Quoted 1 line
iptables -t -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
then, I issue the command >iptables -t nat -L.
the result is
Chain POSTROUTING (policy ACCEPT)
target DNAT
prot all
opt --
source anywhere
destination 0.0.0.0 to:0.0.0.0
I gave the command with verbose
Quoted 1 line
iptables -v -t -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
it showed
DNAT all opt -- in * out * 0.0.0.0/0 -> 0.0.0.0 to:0.0.0.0
for any command which has an ipaddress, the ip address always is always takes as 0.0.0.0
I am using Redhat Linux 2.4.25
iptables v1.3.3
MIPS embedded system.
I am confused. Any help will be greatly appreciated.
regards
Salim
Quoted 5 lines
Hello all,
I am not able to set any rule that contsin ip address in the iptables.
For example I give this commandQuoted 1 line
iptables -t -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
^^^^^^^^^^^^^^^^
-t nat -A PREROUTING
You forgot "nat" after -t. Is that a typo or is this the actual rule you are using ?
Quoted 10 lines
then, I issue the command >iptables -t nat -L.
the result is
Chain POSTROUTING (policy ACCEPT)
target DNAT
prot all
opt --
source anywhere
destination 0.0.0.0 to:0.0.0.0
You just added a PREROUTING rule, and now you're checking if a POSTROUTING rule is correct...
Furthermore : POSTROUTING doesn't have DNAT (it has SNAT) so the result of "iptables -t nat -L" are probably not copy-and-pasted.
Quoted 5 lines
I gave the command with verbose
Quoted 1 line
iptables -v -t -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
it showed
DNAT all opt -- in * out * 0.0.0.0/0 -> 0.0.0.0 to:0.0.0.0
Again : -t nat
...
Quoted 1 line
I am confused. Any help will be greatly appreciated.
Don't know if it will solve your problem but :
- use "-t nat", not just "-t"
- check the chain you're adding a rule to (if it's PREROUTING, check PREROUTING, not POSTROUTING)
Gr,
Rob
Quoted 5 lines
Hello all,
I am not able to set any rule that contsin ip address in the iptables.
For example I give this commandQuoted 1 line
iptables -t -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
^^^^^^^^^^^^^^^^
-t nat -A PREROUTING
You forgot "nat" after -t. Is that a typo or is this the actual rule you are using ?
[Salim] sorry, that was a typo. the actual rule includes -t nat
Quoted 10 lines
then, I issue the command >iptables -t nat -L.
the result is
Chain POSTROUTING (policy ACCEPT)
target DNAT
prot all
opt --
source anywhere
destination 0.0.0.0 to:0.0.0.0
You just added a PREROUTING rule, and now you're checking if a POSTROUTING rule is correct...
Furthermore : POSTROUTING doesn't have DNAT (it has SNAT) so the result of "iptables -t nat -L" are probably not copy-and-pasted.
[Salim] again, it was another typo. it is PREROUTING chain. my linux is in another machine, so I couldn't copy and paste. I typed in manually.
Quoted 5 lines
I gave the command with verbose
Quoted 1 line
iptables -v -t -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
it showed
DNAT all opt -- in * out * 0.0.0.0/0 -> 0.0.0.0 to:0.0.0.0
Again : -t nat
...
Quoted 1 line
I am confused. Any help will be greatly appreciated.
Don't know if it will solve your problem but :
- use "-t nat", not just "-t"
- check the chain you're adding a rule to (if it's PREROUTING, check PREROUTING, not POSTROUTING)
Gr,
Rob
this issue has been solved. seems like 'unsigned long long' doesn't work on my system. changed 'strtoull' to 'strtoul'. Now it looks okay. thanks for all who have spent time on my question.
----- Original Message -----
From: "Salim" <[email protected]>
To: <[email protected]>
Sent: Monday, September 05, 2005 2:01 PM
Subject: iptables: can't set any ip address in rules
Hello all,
I am not able to set any rule that contsin ip address in the iptables.
For example I give this command
Quoted 1 line
iptables -t -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
then, I issue the command >iptables -t nat -L.
the result is
Chain POSTROUTING (policy ACCEPT)
target DNAT
prot all
opt --
source anywhere
destination 0.0.0.0 to:0.0.0.0
I gave the command with verbose
Quoted 1 line
iptables -v -t -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
it showed
DNAT all opt -- in * out * 0.0.0.0/0 -> 0.0.0.0 to:0.0.0.0
for any command which has an ipaddress, the ip address always is always takes as 0.0.0.0
I am using Redhat Linux 2.4.25
iptables v1.3.3
MIPS embedded system.
I am confused. Any help will be greatly appreciated.
regards
Salim
Please add a protocol to your rules (-p TCP or -p UDP) and it will work.
Regards,
Sascha
Quoted 54 lines · Salim
this issue has been solved. seems like 'unsigned long long' doesn't work on my system. changed 'strtoull' to 'strtoul'. Now it looks okay. thanks for all who have spent time on my question.
----- Original Message -----
From: "Salim" <[email protected]>
To: <[email protected]>
Sent: Monday, September 05, 2005 2:01 PM
Subject: iptables: can't set any ip address in rulesHello all,
I am not able to set any rule that contsin ip address in the iptables.
For example I give this commandQuoted 1 line
iptables -t -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
then, I issue the command >iptables -t nat -L.
the result is
Chain POSTROUTING (policy ACCEPT)
target DNAT
prot all
opt --
source anywhere
destination 0.0.0.0 to:0.0.0.0I gave the command with verbose
Quoted 1 line
iptables -v -t -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
it showed
DNAT all opt -- in * out * 0.0.0.0/0 -> 0.0.0.0 to:0.0.0.0for any command which has an ipaddress, the ip address always is always takes as 0.0.0.0
I am using Redhat Linux 2.4.25
iptables v1.3.3
MIPS embedded system.I am confused. Any help will be greatly appreciated.
regards
Salim
Quoted 1 line
Please add a protocol to your rules (-p TCP or -p UDP) and it will work.
Could you explain why that is required ? Salim does not specify any port in his rule.
Gr,
Rob
Argh, i mean please add a protocol to the rule, and add the nat table to the rule.. you always use -t but you do not specify the nat table.. in your rules "-t" should be replaced with "-t nat"
regards,
sascha
Quoted 54 lines · Salim
this issue has been solved. seems like 'unsigned long long' doesn't work on my system. changed 'strtoull' to 'strtoul'. Now it looks okay. thanks for all who have spent time on my question.
----- Original Message -----
From: "Salim" <[email protected]>
To: <[email protected]>
Sent: Monday, September 05, 2005 2:01 PM
Subject: iptables: can't set any ip address in rulesHello all,
I am not able to set any rule that contsin ip address in the iptables.
For example I give this commandQuoted 1 line
iptables -t -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
then, I issue the command >iptables -t nat -L.
the result is
Chain POSTROUTING (policy ACCEPT)
target DNAT
prot all
opt --
source anywhere
destination 0.0.0.0 to:0.0.0.0I gave the command with verbose
Quoted 1 line
iptables -v -t -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
it showed
DNAT all opt -- in * out * 0.0.0.0/0 -> 0.0.0.0 to:0.0.0.0for any command which has an ipaddress, the ip address always is always takes as 0.0.0.0
I am using Redhat Linux 2.4.25
iptables v1.3.3
MIPS embedded system.I am confused. Any help will be greatly appreciated.
regards
Salim
no Sascha, it was not the problem with protocol. And yes, i added -t nat to the rule, it was a typing error that i missed it in the post. for DNAT, I reckon, it is not necessary to add protocol, unless port number is specified.
The problem was with strtoull function, I changed it to strtoul and it works fine.
thanks
----- Original Message -----
From: "Sascha Reissner" <[email protected]>
To: "Salim" <[email protected]>
Cc: <[email protected]>
Sent: Wednesday, September 07, 2005 4:43 PM
Subject: Re: iptables: can't set any ip address in rules
Quoted 9 lines
Argh, i mean please add a protocol to the rule, and add the nat table to the rule.. you always use -t but you do not specify the nat table.. in your rules "-t" should be replaced with "-t nat"
regards,
saschaQuoted 1 line · Salim
this issue has been solved. seems like 'unsigned long long' doesn't work
on
Quoted 10 lines
Quoted 10 lines
my system. changed 'strtoull' to 'strtoul'. Now it looks okay. thanks for all who have spent time on my question.
----- Original Message -----
From: "Salim" <[email protected]>
To: <[email protected]>
Sent: Monday, September 05, 2005 2:01 PM
Subject: iptables: can't set any ip address in rules
Quoted 2 lines
Quoted 2 lines
Hello all,
I am not able to set any rule that contsin ip address in the
iptables.
Quoted 42 lines
Quoted 41 lines
For example I give this command
Quoted 1 line
iptables -t -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
then, I issue the command >iptables -t nat -L.
the result is
Chain POSTROUTING (policy ACCEPT)
target DNAT
prot all
opt --
source anywhere
destination 0.0.0.0 to:0.0.0.0I gave the command with verbose
Quoted 1 line
iptables -v -t -A PREROUTING -d 1.1.1.1 -j DNAT --to-destination 2.2.2.2
it showed
DNAT all opt -- in * out * 0.0.0.0/0 -> 0.0.0.0 to:0.0.0.0for any command which has an ipaddress, the ip address always is always takes as 0.0.0.0
I am using Redhat Linux 2.4.25
iptables v1.3.3
MIPS embedded system.I am confused. Any help will be greatly appreciated.
regards
Salim