Skip to contentSkip to conversation

iptables and martian filtering

DISCUSSION pankaj jain 2 participants 4 messages Jun 6, 2007 netfilter

lore
Share & tools
lore
#0 lore raw

HI,
I am learning how iptables work, so I was writing rules for PREROUTING chain in nat table
I was trying to change the destination address in the incoming packet to 127.x.x.x IP.
since my server is listening on that interface.

I added following rules:
iptables -I PREROUTING -t nat -p tcp -d 192.168.1.10 --dport 23456 -j DNAT --to-destination 127.0.0.3
iptables -I INPUT -p tcp -d 127.0.0.3 -j ACCEPT
iptables -I INPUT -p tcp -i lo -j ACCEPT
iptables -I OUTPUT -p tcp -s 127.0.0.3 -j ACCEPT
iptables -I OUTPUT -p tcp -o lo -j ACCEPT

server is listening on 127.0.0.3:23456
client is trying to connect to 192.168.1.10:23456

but client is not able to connect to the server
I was getting logs such as "martian destination 127.0.0.3 from 192.168.1.10, dev eth0" in dmesg.

I believe "Martian Address Filtering" is taking place. is there any way to override this filtering action ?

Signature · 2 lines
Thanks
Pankaj Jain
#1 lore raw
Quoted 1 line · pankaj jain

Subject: iptables and martian filtering

iptables -A INPUT -s mars -j DROP
iptables -A INPUT -m martian -j DROP

SCNR ;-)

Quoted 6 lines

HI,
I am learning how iptables work, so I was writing rules for PREROUTING chain in nat table
I was trying to change the destination address in the incoming packet to 127.x.x.x IP.
since my server is listening on that interface.

No. Every linux box always listens on all 16 million 127.0.0.0/8 addresses, so trying to make it use something else than 127.0.0.1 is almost always meaningless.

Quoted 3 lines

I added following rules:
iptables -I PREROUTING -t nat -p tcp -d 192.168.1.10 --dport 23456 -j DNAT --to-destination 127.0.0.3

DNAT to localhost does not work, use REDIRECT.

Quoted 8 lines

iptables -I INPUT -p tcp -d 127.0.0.3 -j ACCEPT
iptables -I INPUT -p tcp -i lo -j ACCEPT
iptables -I OUTPUT -p tcp -s 127.0.0.3 -j ACCEPT
iptables -I OUTPUT -p tcp -o lo -j ACCEPT

server is listening on 127.0.0.3:23456
client is trying to connect to 192.168.1.10:23456

Quoted 12 lines

but client is not able to connect to the server
I was getting logs such as "martian destination 127.0.0.3 from 192.168.1.10, dev eth0" in dmesg.

I believe "Martian Address Filtering" is taking place. is there any way to override this filtering action ?

Signature · 2 lines
Thanks
Pankaj Jain

Jan

#2 lore raw

Hi Jan
Thanks for your response.
I want to accept the martian packets so I replaced DROP with ACCEPT in the suggested rules and applied.
still my client is not able to connect to the server.
I dont want to use the 127.0.0.1 IP for my server.

The REDIRECT rule does not have any option to provide the IP <127.0.0.3>

Quoted 51 lines · Jan Engelhardt
Quoted 1 line · pankaj jain

Subject: iptables and martian filtering

iptables -A INPUT -s mars -j DROP
iptables -A INPUT -m martian -j DROP

SCNR ;-)

Quoted 6 lines

HI,
I am learning how iptables work, so I was writing rules for PREROUTING chain in nat table
I was trying to change the destination address in the incoming packet to 127.x.x.x IP.
since my server is listening on that interface.

No. Every linux box always listens on all 16 million 127.0.0.0/8 addresses, so trying to make it use something else than 127.0.0.1 is almost always meaningless.

Quoted 3 lines

I added following rules:
iptables -I PREROUTING -t nat -p tcp -d 192.168.1.10 --dport 23456 -j DNAT --to-destination 127.0.0.3

DNAT to localhost does not work, use REDIRECT.

Quoted 12 lines

iptables -I INPUT -p tcp -d 127.0.0.3 -j ACCEPT
iptables -I INPUT -p tcp -i lo -j ACCEPT
iptables -I OUTPUT -p tcp -s 127.0.0.3 -j ACCEPT
iptables -I OUTPUT -p tcp -o lo -j ACCEPT

server is listening on 127.0.0.3:23456
client is trying to connect to 192.168.1.10:23456

but client is not able to connect to the server
I was getting logs such as "martian destination 127.0.0.3 from 192.168.1.10, dev eth0" in dmesg.

Quoted 8 lines

I believe "Martian Address Filtering" is taking place. is there any way to override this filtering action ?

--
Thanks
Pankaj Jain

Jan
--

Signature · 2 lines
Thanks
Pankaj Jain
#3 lore raw
Quoted 4 lines · pankaj jain

I want to accept the martian packets so I replaced DROP with ACCEPT in the suggested rules and applied.
still my client is not able to connect to the server.
I dont want to use the 127.0.0.1 IP for my server.

You _cannot_ not use 127.0.0.1. (Note the double inversion.)

Try it yourself: telnet 127.3.13.37 22
should give you your sshd. *Any* IP address from 127.0.0.0/8 will. Therefore it is pointless to be using anything else besides 127.0.0.1.

Quoted 54 lines

The REDIRECT rule does not have any option to provide the IP <127.0.0.3>

Quoted 50 lines · Jan Engelhardt
Quoted 1 line · pankaj jain

Subject: iptables and martian filtering

iptables -A INPUT -s mars -j DROP
iptables -A INPUT -m martian -j DROP

SCNR ;-)

Quoted 7 lines

HI,
I am learning how iptables work, so I was writing rules for PREROUTING
chain in nat table
I was trying to change the destination address in the incoming packet to 127.x.x.x IP.
since my server is listening on that interface.

No. Every linux box always listens on all 16 million 127.0.0.0/8 addresses,
so trying to make it use something else than 127.0.0.1 is almost always meaningless.

Quoted 3 lines

I added following rules:
iptables -I PREROUTING -t nat -p tcp -d 192.168.1.10 --dport 23456 -j DNAT --to-destination 127.0.0.3

DNAT to localhost does not work, use REDIRECT.

Quoted 20 lines

iptables -I INPUT -p tcp -d 127.0.0.3 -j ACCEPT
iptables -I INPUT -p tcp -i lo -j ACCEPT
iptables -I OUTPUT -p tcp -s 127.0.0.3 -j ACCEPT
iptables -I OUTPUT -p tcp -o lo -j ACCEPT

server is listening on 127.0.0.3:23456
client is trying to connect to 192.168.1.10:23456

but client is not able to connect to the server
I was getting logs such as "martian destination 127.0.0.3 from 192.168.1.10, dev eth0" in dmesg.

I believe "Martian Address Filtering" is taking place. is there any way to override this filtering action ?

--
Thanks
Pankaj Jain

Quoted 9 lines
Quoted 3 lines

Jan
--

Signature · 2 lines
Thanks
Pankaj Jain

Jan