Skip to contentSkip to conversation

redirection trouble

DISCUSSION Martín 2 participants 3 messages Nov 4, 2003 – Nov 28, 2003 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Martín

author
#1 lore raw

Ok, I think I got it... but does not work. I see the traffic being redirected, but the conection gets lost, I got this in the snuiffer:

02:02:51.640513 192.168.2.1 > 192.168.2.5: icmp: 192.168.2.1 udp port 10000 unrachable [tos 0x40]

Any Idea?

Quoted 73 lines · Edmund Turner

Martin, Alistairs explanation and solution is correct. In short 192.168.2.5 will only see traffic thru and fro 192.168.2.1 @port 10000. Put a packet analyser or a sniffer on 192.168.2.5 to confirm.
In Iptables if you do a prerouting as such :

#This will redirect all packets to 192.168.2.1 dport 10000 to 200.24.24.200:10000

iptables -t nat -I PREROUTING -i eth1 -d 192.168.2.1 -p udp --dport

Quoted 1 line

10000 -j DNAT --to 200.45.45.200:10000

You don’t have to worry about the packets coming in back from 200.24.24.200. They will be tracked and sent back to 192.168.2.5 as source IP of 192.168.2.1. Im not sure which module is responsible for this, but I think its done by the ip_conntrack module. Maybe someone can enlighten us on this?

Regards
edmund

Quoted 1 line

-----Original Message-----

From: [email protected] [mailto:[email protected]] On Behalf Of Martín
Sent: Tuesday, November 04, 2003 10:37 AM
To: [email protected]
Cc: [email protected]
Subject: Re: redirection trouble

En Mon, 3 Nov 2003 21:21:09 -0500, Alistair Tonner <[email protected]>

Quoted 10 lines · escribió:
Quoted 9 lines · Martín

This is the situation:

Internal LAN machine (192.168.2.5)

(eth1 192.168.2.1) NAT LINUX ( eth0 192.168.1.10 > adsl ppp0 IP

dinamic)

Quoted 7 lines
Quoted 7 lines

Server 200.45.45.200 (service at port 10000)

Quoted 7 lines
Quoted 7 lines

This is what I intend to do:
For particular reasons, I need that a soft at 192.168.2.5 comunicate with a server with a service at port 10000 (UDP), but this can´t be done through normal NAT. So i want to establish a link between both (server and 192.168.2.5) manually useing the NAT LINUX
So, 192.168.2.5 comunicates to 192.168.2.1 port 10000, the NAT LINUX redirect this traffic to the server 200.45.45.200 port 10000. The

server

Quoted 11 lines
Quoted 11 lines

will respond to the NAT LINUX who will redirect this traffic to 192.168.2.5 (port 10000 also)
I try to do all this in this way:

iptables -t nat -I PREROUTING 1 -i eth1 -d 192.168.2.1 -p udp --dport

10000
-j DNAT --to 200.45.45.200

iptables -t nat -I POSTROUTING 1 -o eth0 -p udp --dport 10000 -j SNAT

Signature · 1 line
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
#2 lore raw
Quoted 7 lines · Martín

Ok, I think I got it... but does not work. I see the traffic being redirected, but the conection gets lost, I got this in the snuiffer:

02:02:51.640513 192.168.2.1 > 192.168.2.5: icmp: 192.168.2.1 udp port 10000 unrachable [tos 0x40]

Any Idea?

Ummm what exists between the linux NAT box and the internet itself?

Do you have another router in there?
what is meant by: ( eth0 192.168.1.10 > adsl ppp0 IP dinamic) Typically adsl direct connected routers to ppp daemons should NOT have an ip on the ethernet interface unless you need to manage the router. However I digress.

Can you see the packet (after DNATting) on the way out ppp0?

What if any other rules have you in the FORWARD chain.

*thunks head on table* You will need to FORWARD the packets through the box as well as DNATting the packets.

iptables -I FORWARD -p udp -s 192.168.2.5 -d 200.24.24.200 --dport 10000 -j
ACCEPT

And again, depeinding on the presence of ESTABLISHED RELATED rules you may
need to return them through the FORWARD chain

Sometimes assumption of anything will get us in trouble.

Quoted 83 lines

En Tue, 4 Nov 2003 11:20:42 +0800, Edmund Turner <[email protected]>

Quoted 76 lines · escribió:

Martin, Alistairs explanation and solution is correct. In short 192.168.2.5 will only see traffic thru and fro 192.168.2.1 @port 10000. Put a packet analyser or a sniffer on 192.168.2.5 to confirm.
In Iptables if you do a prerouting as such :

#This will redirect all packets to 192.168.2.1 dport 10000 to 200.24.24.200:10000

iptables -t nat -I PREROUTING -i eth1 -d 192.168.2.1 -p udp --dport

Quoted 1 line

10000 -j DNAT --to 200.45.45.200:10000

You don’t have to worry about the packets coming in back from 200.24.24.200. They will be tracked and sent back to 192.168.2.5 as source IP of 192.168.2.1. Im not sure which module is responsible for this, but I think its done by the ip_conntrack module. Maybe someone can enlighten us on this?

Regards
edmund

Quoted 1 line

-----Original Message-----

From: [email protected] [mailto:[email protected]] On Behalf Of Martín
Sent: Tuesday, November 04, 2003 10:37 AM
To: [email protected]
Cc: [email protected]
Subject: Re: redirection trouble

En Mon, 3 Nov 2003 21:21:09 -0500, Alistair Tonner <[email protected]>

Quoted 10 lines · escribió:
Quoted 9 lines · Martín

This is the situation:

Internal LAN machine (192.168.2.5)

(eth1 192.168.2.1) NAT LINUX ( eth0 192.168.1.10 > adsl ppp0 IP

dinamic)

Quoted 4 lines
Quoted 4 lines

Server 200.45.45.200 (service at port 10000)

Quoted 9 lines
Quoted 9 lines

This is what I intend to do:
For particular reasons, I need that a soft at 192.168.2.5 comunicate with a
server with a service at port 10000 (UDP), but this can´t be done through
normal NAT. So i want to establish a link between both (server and 192.168.2.5) manually useing the NAT LINUX
So, 192.168.2.5 comunicates to 192.168.2.1 port 10000, the NAT LINUX redirect this traffic to the server 200.45.45.200 port 10000. The

server

Quoted 12 lines
Quoted 12 lines

will respond to the NAT LINUX who will redirect this traffic to 192.168.2.5
(port 10000 also)
I try to do all this in this way:

iptables -t nat -I PREROUTING 1 -i eth1 -d 192.168.2.1 -p udp --dport

10000
-j DNAT --to 200.45.45.200

iptables -t nat -I POSTROUTING 1 -o eth0 -p udp --dport 10000 -j SNAT

Signature · 6 lines
	Alistair Tonner
	nerdnet.ca
	Senior Systems Analyst - RSS
	
     Any sufficiently advanced technology will have the appearance of magic.
	Lets get magical!
#3 lore raw
In reply to Martín
Quoted 7 lines · Martín

Ok, I think I got it... but does not work. I see the traffic being redirected, but the conection gets lost, I got this in the snuiffer:

02:02:51.640513 192.168.2.1 > 192.168.2.5: icmp: 192.168.2.1 udp port 10000 unrachable [tos 0x40]

Any Idea?

Ummm what exists between the linux NAT box and the internet itself?

Do you have another router in there?
what is meant by: ( eth0 192.168.1.10 > adsl ppp0 IP dinamic) Typically adsl direct connected routers to ppp daemons should NOT have an ip on the ethernet interface unless you need to manage the router. However I digress.

Can you see the packet (after DNATting) on the way out ppp0?

What if any other rules have you in the FORWARD chain.

*thunks head on table* You will need to FORWARD the packets through the box as well as DNATting the packets.

iptables -I FORWARD -p udp -s 192.168.2.5 -d 200.24.24.200 --dport 10000 -j
ACCEPT

And again, depeinding on the presence of ESTABLISHED RELATED rules you may
need to return them through the FORWARD chain

Sometimes assumption of anything will get us in trouble.

Quoted 83 lines

En Tue, 4 Nov 2003 11:20:42 +0800, Edmund Turner <[email protected]>

Quoted 76 lines · escribió:

Martin, Alistairs explanation and solution is correct. In short 192.168.2.5 will only see traffic thru and fro 192.168.2.1 @port 10000. Put a packet analyser or a sniffer on 192.168.2.5 to confirm.
In Iptables if you do a prerouting as such :

#This will redirect all packets to 192.168.2.1 dport 10000 to 200.24.24.200:10000

iptables -t nat -I PREROUTING -i eth1 -d 192.168.2.1 -p udp --dport

Quoted 1 line

10000 -j DNAT --to 200.45.45.200:10000

You don’t have to worry about the packets coming in back from 200.24.24.200. They will be tracked and sent back to 192.168.2.5 as source IP of 192.168.2.1. Im not sure which module is responsible for this, but I think its done by the ip_conntrack module. Maybe someone can enlighten us on this?

Regards
edmund

Quoted 1 line

-----Original Message-----

From: [email protected] [mailto:[email protected]] On Behalf Of Martín
Sent: Tuesday, November 04, 2003 10:37 AM
To: [email protected]
Cc: [email protected]
Subject: Re: redirection trouble

En Mon, 3 Nov 2003 21:21:09 -0500, Alistair Tonner <[email protected]>

Quoted 10 lines · escribió:
Quoted 9 lines · Martín

This is the situation:

Internal LAN machine (192.168.2.5)

(eth1 192.168.2.1) NAT LINUX ( eth0 192.168.1.10 > adsl ppp0 IP

dinamic)

Quoted 4 lines
Quoted 4 lines

Server 200.45.45.200 (service at port 10000)

Quoted 9 lines
Quoted 9 lines

This is what I intend to do:
For particular reasons, I need that a soft at 192.168.2.5 comunicate with a
server with a service at port 10000 (UDP), but this can´t be done through
normal NAT. So i want to establish a link between both (server and 192.168.2.5) manually useing the NAT LINUX
So, 192.168.2.5 comunicates to 192.168.2.1 port 10000, the NAT LINUX redirect this traffic to the server 200.45.45.200 port 10000. The

server

Quoted 12 lines
Quoted 12 lines

will respond to the NAT LINUX who will redirect this traffic to 192.168.2.5
(port 10000 also)
I try to do all this in this way:

iptables -t nat -I PREROUTING 1 -i eth1 -d 192.168.2.1 -p udp --dport

10000
-j DNAT --to 200.45.45.200

iptables -t nat -I POSTROUTING 1 -o eth0 -p udp --dport 10000 -j SNAT

Signature · 6 lines
	Alistair Tonner
	nerdnet.ca
	Senior Systems Analyst - RSS
	
     Any sufficiently advanced technology will have the appearance of magic.
	Lets get magical!