Skip to contentSkip to conversation

loopback forwarding not working (aka implicit source local NAT)

DISCUSSION d i 2 participants 6 messages Sep 17, 2008 – Sep 18, 2008 netfilter

lore
Share & tools
lore

d i

author
#0 lore raw

Hi,
I understood that iptables (my version is 1.4.0) do not longer support implicit source local NAT, i.e., the effect of iptables -t nat -A OUTPUT -p tcp --dport 222 -t DNAT --to-destination ${LANIP}:22
which allows one to write on the local machine:
ssh -p 222 localhost
and connect to the LAN machine with address ${LANIP} on the ssh port.

Can you please confirm this is no longer available ? I get no error when I use it, but it doesn't work either... (while logging, the packets in the OUTPUT chain have destination 127.0.0.1, although it should be ${LANIP}; also the port is the same 222)

Is there a way to activate/enable it ?
If not, is there a way around it? I (would prefer not to have high level applications that do this, but rather do it in the kernel)

Quoted 1 line

From a developer point of view it might seem useless to have something like this, since at any time one could just directly connect to that destination:port, without a loopback forwarding. However, I think this is at least useful for my particular situation:

I am a subnet inside another subnet and I have no access to the public router, other than getting DNS and having my connections routed.
So my WAN IP is not public. In order to access my router from the outside world, I am using a reverse ssh tunnel to a computer which is public and to which I have access. This reverse ssh tunnel is nothing but remote port forwarding of the ssh.

Using this reverse ssh tunnel, I can connect (ssh) to my router directly from outside by connecting to a local port on that public computer.

I would like to have the same for the other machines in my subnet:
I want to forward some ports on my router towards the ssh ports of my LAN machines, and using the ssh reverse tunnel port forwarding I can connect to them from the outside world. This is where I would need the implicit source local NAT: these ports would be forwarded (by iptables) towards my subnet machines (ssh port).

Thanks for any help!

PS: please CC any response to my email address.
PS2: sorry if this is not the typical message bound for the netfilter-devel, but I've asked this on the users mail list as well, and I got no answer...
_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE

#1 lore raw
Quoted 13 lines · d i

Hi,
I understood that iptables (my version is 1.4.0) do not longer support implicit source local NAT, i.e., the effect of iptables -t nat -A OUTPUT -p tcp --dport 222 -t DNAT --to-destination ${LANIP}:22
which allows one to write on the local machine:
ssh -p 222 localhost
and connect to the LAN machine with address ${LANIP} on the ssh port.

Can you please confirm this is no longer available ? I get no error when I use it, but it doesn't work either... (while logging, the packets in the OUTPUT chain have destination 127.0.0.1, although it should be ${LANIP}; also the port is the same 222)

Quoted 4 lines

Is there a way to activate/enable it ?

If not, is there a way around it? I (would prefer not to have high level applications that do this, but rather do it in the kernel)

iptables -t raw -A OUTPUT

Quoted 17 lines

From a developer point of view it might seem useless to have something like this, since at any time one could just directly connect to that destination:port, without a loopback forwarding. However, I think this is at least useful for my particular situation:

I am a subnet inside another subnet and I have no access to the public router, other than getting DNS and having my connections routed. So my WAN IP is not public. In order to access my router from the outside world, I am using a reverse ssh tunnel to a computer which is public and to which I have access. This reverse ssh tunnel is nothing but remote port forwarding of the ssh.

Using this reverse ssh tunnel, I can connect (ssh) to my router directly from outside by connecting to a local port on that public computer.

Quoted 6 lines

I would like to have the same for the other machines in my subnet: I want to forward some ports on my router towards the ssh ports of my LAN machines, and using the ssh reverse tunnel port forwarding I can connect to them from the outside world. This is where I would need the implicit source local NAT: these ports would be forwarded (by iptables) towards my subnet machines (ssh port).

Can't you just use a VPN solution like ipsec/openvpn for this?

author
#2 lore raw
Quoted 2 lines

iptables -t raw -A OUTPUT

with what target ? raw table i think only accepts TRACE and NOTRACK targets, and none of them works with --to ${LANIP}:port

i actually tried with the DNAT target as well for this, but ends up in error.

can you please write the whole rule ? is this together with the iptables -t nat -A OUTPUT -p tcp -DNAT --dport 222 --to ${LANIP}:22 or just by itself ?

Quoted 1 line

Can't you just use a VPN solution like ipsec/openvpn for this?

any commercial application is likely to create extra unnecessary overhead and complications. a kernel based solution is much cleaner and lighter. yes, i have the ssh on top of it, but i can live with that. i'm using the tunnel for other things as well.

thanks!
_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE

#3 lore raw
Quoted 7 lines · d i
Quoted 2 lines

Can't you just use a VPN solution like ipsec/openvpn for this?

any commercial application is likely to create extra unnecessary overhead and complications. a kernel based solution is much cleaner and lighter. yes, i have the ssh on top of it, but i can live with that. i'm using the tunnel for other things as well.

Then openswan is probably your best bet.

author
#4 lore raw
Quoted 7 lines
Quoted 5 lines

any commercial application is likely to create extra unnecessary overhead and complications. a kernel based solution is much cleaner and lighter. yes, i have the ssh on top of it, but i can live with that. i'm using the tunnel for other things as well.

Then openswan is probably your best bet.

you know, i have 2 machines in my subnet, and my router is a 20 years old thing, with 64MB Ram, and 166 MHz...
this openswan and vpn in general, seem to me dedicate for larger and more .... professional environments. I will look into your suggestion of using openswan, but (based on my knowledge so far) i would really prefer something more basic, light and simple

searching more on the net I found some references to the RAWDNET and RAWSNET targets for the RAW table. but neither work with my iptables (ver. 1.4.0)

is there any information available about this by any chance ? could you tell me anything more about the RAW table, that is not in the man pagel (there isn't much in the man page about this)?

thanks!
_________________________________________________________________
Connect to the next generation of MSN Messenger
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html