Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Iptables and SNAT help
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
ksool
Guru
Guru


Joined: 27 May 2006
Posts: 337
Location: Cambridge, MA

PostPosted: Tue Sep 04, 2007 5:34 am    Post subject: [Solved] Iptables and SNAT help Reply with quote

Hey all. I'm trying to modify my iptables setup but let me describe the network first.
Couple local machines on 192.168.1.0/24. Router at 192.168.1.1 and a public ip.

Right now, I have a couple of services running behind my firewall which are accessible to the public. I also have basic NAT running. What I would like would be to allow the local machines to access the services through the router. That is, indirectly. Ideally, It would be something like 192.168.1.2 requests tcp port 80 from the public ip and the router establishes a connection to the http server as if it were a connection from the public. Like this, theoretically, the client should never have to know the private ip of the server and vice versa. Hope that's clear.

<removed>


Last edited by ksool on Sat Sep 15, 2007 3:28 am; edited 1 time in total
Back to top
View user's profile Send private message
nixnut
Bodhisattva
Bodhisattva


Joined: 09 Apr 2004
Posts: 10974
Location: the dutch mountains

PostPosted: Tue Sep 04, 2007 4:44 pm    Post subject: Reply with quote

That scenario is described here
_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered

talk is cheap. supply exceeds demand
Back to top
View user's profile Send private message
sschlueter
Guru
Guru


Joined: 26 Jul 2002
Posts: 578
Location: Dortmund, Germany

PostPosted: Tue Sep 04, 2007 11:19 pm    Post subject: Reply with quote

If the client and the server are in the the same subnet (and the log suggests that they are), then a simple DNAT is not enough. The reasonis that the server sends its response directly to the client, where it is discarded as an unsolicited packet.

You need to set up a DNAT rule in the PREROUTING chain to change the destination IP to that of the server and set up a SNAT rule in the POSTROUTING chanin to change the source IP to that of the router.
Back to top
View user's profile Send private message
ksool
Guru
Guru


Joined: 27 May 2006
Posts: 337
Location: Cambridge, MA

PostPosted: Sat Sep 15, 2007 3:27 am    Post subject: Reply with quote

Thanks. Worked like a charm.

That's a fantastically thorough iptables by the way. Much appreciated.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum