Skip to contentSkip to conversation

PREROUTING to a non local subnet

DISCUSSION Manu 3 participants 5 messages Sep 9, 2013 – Sep 17, 2013 1 message not in the archive

lore
Share & tools
lore

Manu

author
#0 lore raw

Hello

I'm running iptable v1.4.7 on a linux with two NIC. One has adress 192.168.1.31 (the lan)
The other has a public IP. Let's say 180.180.180.180

On the lan, I have a VPN which join two network : 192.168.1.0 and 192.168.2.0

I'm trying to forward 5900 port (vnc) to a computer which is on the second subnet with adress 192.168.2.100 iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 5900 -j DNAT --to-destination 192.168.2.100:5900 iptables -A FORWARD -p tcp -d 192.168.2.100--dport 5900 -j ACCEPT
and it doesn't work

I've tried the same on the local network with adress 192.168.1.99
iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 5900 -j DNAT --to-destination 192.168.1.99:5900 iptables -A FORWARD -p tcp -d 192.168.1.99--dport 5900 -j ACCEPT
and it's working like a charm

I've done my test with another computer with public adress 200.200.200.200

I've done a netstat one the two computers
on 192.168.2.100 i've seen he's talking to 180.180.180.180 (<-- my server running iptable)
on 192.168.1.99 i've seen he's talking to 200.200.200.200 (<-- the computer on internet which i'm running my test from)

thanks for your attention

author
#1 lore raw

Hello

Nobody knows if it possible ?

Quoted 32 lines · Manu

Hello

I'm running iptable v1.4.7 on a linux with two NIC. One has adress 192.168.1.31 (the lan)
The other has a public IP. Let's say 180.180.180.180

On the lan, I have a VPN which join two network : 192.168.1.0 and 192.168.2.0

I'm trying to forward 5900 port (vnc) to a computer which is on the second subnet with adress 192.168.2.100 iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 5900 -j DNAT
--to-destination 192.168.2.100:5900
iptables -A FORWARD -p tcp -d 192.168.2.100--dport 5900 -j ACCEPT
and it doesn't work

I've tried the same on the local network with adress 192.168.1.99 iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 5900 -j DNAT --to-destination 192.168.1.99:5900
iptables -A FORWARD -p tcp -d 192.168.1.99--dport 5900 -j ACCEPT and it's working like a charm

I've done my test with another computer with public adress 200.200.200.200

I've done a netstat one the two computers
on 192.168.2.100 i've seen he's talking to 180.180.180.180 (<-- my server running iptable)
on 192.168.1.99 i've seen he's talking to 200.200.200.200 (<-- the computer on internet which i'm running my test from)

thanks for your attention

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Hi,

Try to include a source NAT rule to ensure symmetrical routing.

iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 5900 -j DNAT --to-destination 192.168.2.100:5900
iptables -A POSTROUTING -t nat -p tcp -d 192.168.2.100 --dport 5900 -j MASQUERADE
iptables -A FORWARD -p tcp -d 192.168.2.100--dport 5900 -j ACCEPT

2013/9/16 Manu <[email protected]>:

Quoted 47 lines

Hello

Nobody knows if it possible ?

Quoted 31 lines · Manu

Hello

I'm running iptable v1.4.7 on a linux with two NIC. One has adress 192.168.1.31 (the lan)
The other has a public IP. Let's say 180.180.180.180

On the lan, I have a VPN which join two network : 192.168.1.0 and 192.168.2.0

I'm trying to forward 5900 port (vnc) to a computer which is on the second subnet with adress 192.168.2.100
iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 5900 -j DNAT --to-destination 192.168.2.100:5900
iptables -A FORWARD -p tcp -d 192.168.2.100--dport 5900 -j ACCEPT and it doesn't work

I've tried the same on the local network with adress 192.168.1.99 iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 5900 -j DNAT --to-destination 192.168.1.99:5900
iptables -A FORWARD -p tcp -d 192.168.1.99--dport 5900 -j ACCEPT and it's working like a charm

I've done my test with another computer with public adress 200.200.200.200

I've done a netstat one the two computers
on 192.168.2.100 i've seen he's talking to 180.180.180.180 (<-- my server running iptable)
on 192.168.1.99 i've seen he's talking to 200.200.200.200 (<-- the computer on internet which i'm running my test from)

Quoted 6 lines

thanks for your attention
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe netfilter" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Manu
Quoted 6 lines · Manu

Hello

I'm running iptable v1.4.7 on a linux with two NIC. One has adress 192.168.1.31 (the lan)
The other has a public IP. Let's say 180.180.180.180

Quoted 7 lines

On the lan, I have a VPN which join two network : 192.168.1.0 and 192.168.2.0

I'm trying to forward 5900 port (vnc) to a computer which is on the second subnet with adress 192.168.2.100 iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 5900 -j DNAT
--to-destination 192.168.2.100:5900
iptables -A FORWARD -p tcp -d 192.168.2.100--dport 5900 -j ACCEPT
and it doesn't work

Does this machine have route to 192.168.2.0 network? Try to use tcpdump and see where the traffic is being dropped.

Regards,
Vignesh

Quoted 19 lines

I've tried the same on the local network with adress 192.168.1.99 iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 5900 -j DNAT --to-destination 192.168.1.99:5900
iptables -A FORWARD -p tcp -d 192.168.1.99--dport 5900 -j ACCEPT and it's working like a charm

I've done my test with another computer with public adress 200.200.200.200

I've done a netstat one the two computers
on 192.168.2.100 i've seen he's talking to 180.180.180.180 (<-- my server running iptable)
on 192.168.1.99 i've seen he's talking to 200.200.200.200 (<-- the computer on internet which i'm running my test from)

thanks for your attention

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

#5 lore raw

[seems the mailing list IP is missed. adding it]

Quoted 4 lines · Manu

For me the traffic is being dropped in the right place as when I do a netstat on the 192.168.2.100 I see that there is an open connection with 180.180.180.180 (<-- my server running iptable). But the IP of the computer i'm running my test from is 200.200.200.200
There is the strange point as when I use the same rules for forwarding a port to a computer on the same subnet than the server i see a connection from 200.200.200.200 and not 180.180.180.180 It seem that iptables rewrite the from ip adresse when it does port forwarding to a computer which is not on the same subnet.

I think, some SNAT rule is doing that (may be as a side effect of your VPN configuration?).

Quoted 1 line

I hope 'im clear enough. Tell me if it is not the case.

Regards,
Vignesh

Quoted 47 lines · Vigneswaran R
Quoted 45 lines · Manu
Quoted 6 lines

Hello

I'm running iptable v1.4.7 on a linux with two NIC. One has adress 192.168.1.31 (the lan)
The other has a public IP. Let's say 180.180.180.180

Quoted 7 lines

On the lan, I have a VPN which join two network : 192.168.1.0 and 192.168.2.0

I'm trying to forward 5900 port (vnc) to a computer which is on the second subnet with adress 192.168.2.100 iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 5900 -j DNAT
--to-destination 192.168.2.100:5900
iptables -A FORWARD -p tcp -d 192.168.2.100--dport 5900 -j ACCEPT
and it doesn't work

Does this machine have route to 192.168.2.0 network? Try to use tcpdump and see where the traffic is being dropped.

Regards,
Vignesh

Quoted 19 lines

I've tried the same on the local network with adress 192.168.1.99 iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 5900 -j DNAT --to-destination 192.168.1.99:5900
iptables -A FORWARD -p tcp -d 192.168.1.99--dport 5900 -j ACCEPT and it's working like a charm

I've done my test with another computer with public adress 200.200.200.200

I've done a netstat one the two computers
on 192.168.2.100 i've seen he's talking to 180.180.180.180 (<-- my server running iptable)
on 192.168.1.99 i've seen he's talking to 200.200.200.200 (<-- the computer on internet which i'm running my test from)

thanks for your attention

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html