dnatting
Hi,
I have a rule on my friend's broadband connection to redirect traffic from outside to an internal machine like,
iptables -A PREROUTING -d 1.2.3.4 -p tcp -m tcp --dport 80 -j DNAT \
--to-destination 192.168.10.10:80
But she complained that people from inside the network cannot do
http://1.2.3.4 in their browser and see the site. Is she correct? What is wrong with my rule because I can see the site from outside?
Thanks in advance.
With warm regards,
-Payal
Quoted 11 lines
Hi,
I have a rule on my friend's broadband connection to redirect traffic from outside to an internal machine like,iptables -A PREROUTING -d 1.2.3.4 -p tcp -m tcp --dport 80 -j DNAT \
--to-destination 192.168.10.10:80But she complained that people from inside the network cannot do
http://1.2.3.4 in their browser and see the site. Is she correct? What is wrong with my rule because I can see the site from outside?
The packet must pass the machine the DNAT rule is on to make the dnat effective.
Jan Engelhardt
Signature · 1 line
| Alphagate Systems, http://alphagate.hopto.org/
Quoted 8 lines · Jan Engelhardt
Quoted 8 lines
Hi,
I have a rule on my friend's broadband connection to redirect traffic from outside to an internal machine like,iptables -A PREROUTING -d 1.2.3.4 -p tcp -m tcp --dport 80 -j DNAT \
--to-destination 192.168.10.10:80
Quoted 7 lines
Quoted 3 lines
But she complained that people from inside the network cannot do
http://1.2.3.4 in their browser and see the site. Is she correct? What is wrong with my rule because I can see the site from outside?The packet must pass the machine the DNAT rule is on to make the dnat effective.
So what do I do exactly?
With warm regards,
-Payal
Quoted 10 lines · Jan Engelhardt
Quoted 8 lines
I have a rule on my friend's broadband connection to redirect traffic from outside to an internal machine like,
iptables -A PREROUTING -d 1.2.3.4 -p tcp -m tcp --dport 80 -j DNAT \
--to-destination 192.168.10.10:80But she complained that people from inside the network cannot do
http://1.2.3.4 in their browser and see the site. Is she correct? What is wrong with my rule because I can see the site from outside?The packet must pass the machine the DNAT rule is on to make the dnat effective.
And then there should be a filter table rule to ACCEPT those packets, or at least nothing to DROP or otherwise not accept them.
With a typical (Packet-Filtering-HOWTO-inspired) firewall with default DROP policy in FORWARD, you need a corresponding ACCEPT rule in FORWARD for every DNAT. In crafting such rules remember that the destination has already been rewritten in nat/PREROUTING.
The Web proxy suggestion has me puzzled. :)
Signature · 2 lines
mail to this address is discarded unless "/dev/rob0"
or "not-spam" is in Subject: headerQuoted 1 line
The Web proxy suggestion has me puzzled. :)
"me2", because given that 1.2.3.4 is a valid internet-wide IP (e.g. ppp0), 10.x.y.z is the local net (eth0) and a client is 10.0.0.1 on eth0, there should not be any problem to connect from 10.0.0.1 to 1.2.3.4:80 and get it DNAT'ed.
Or do you mean that telnet 127.0.0.1 80 on the DNAT-rulebox itself does not work [anymore]?
Jan Engelhardt
Signature · 1 line
| Alphagate Systems, http://alphagate.hopto.org/
You may need to install, additionally, a web proxy, such as squid and tell iptables to use it as a transparent proxy for all internal machines, like this:
iptables -t nat -A POSTROUTING -s 192.168.10.0/255.255.255.0 -i ethX -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.10.1:3128
where ethX is the interface on the internal network.
-Scott
--- Payal Rathod <[email protected]>
Quoted 16 lines · wrote:
Hi,
I have a rule on my friend's broadband connection to redirect traffic
from outside to an internal machine like,iptables -A PREROUTING -d 1.2.3.4 -p tcp -m tcp
--dport 80 -j DNAT \
--to-destination 192.168.10.10:80But she complained that people from inside the network cannot do
http://1.2.3.4 in their browser and see the site. Is she correct?
What is wrong with my rule because I can see the site from outside?
Quoted 7 lines
Thanks in advance.
With warm regards,
-Payal
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Quoted 10 lines · Payal Rathod
Hi,
I have a rule on my friend's broadband connection to redirect traffic from outside to an internal machine like,iptables -A PREROUTING -d 1.2.3.4 -p tcp -m tcp --dport 80 -j DNAT \
--to-destination 192.168.10.10:80But she complained that people from inside the network cannot do
http://1.2.3.4 in their browser and see the site. Is she correct? What is wrong with my rule because I can see the site from outside?
1) client; say 192.168.10.100, sends TCP SYN to 1.2.3.4
2) iptables machine receives packet destined for 1.2.3.4, DNAT's it to 192.168.10.10 and forwards the packet out the internal interface
3) 192.168.10.10 receives TCP SYN from 192.168.10.100 and replies
directly to 192.168.10.100 with a SYN/ACK
4) client; 192.168.10.100, receives SYN/ACK from 192.168.10.10 and discards it, as it matches no connection in the SYN_SENT state (recall that our SYN was sent to 1.2.3.4).
that the why. the proper way to avoid this is to have people on the inside connect to 192.168.10.10. i will leave all the half-assed work-arounds and kludges as an exercise for the reader and other posters.
-j
--
"Peter: This party couldn't be better if Jesus was here.
Jesus: For my next miracle, I will turn water... into FUNK."
--Family Guy
Quoted 3 lines
4) client; 192.168.10.100, receives SYN/ACK from 192.168.10.10 and discards it, as it matches no connection in the
SYN_SENTstate (recall that our SYN was sent to 1.2.3.4).
Now I get the point of problem. Well, there was *once* implicit SNAT in netfilter (at least in conjunction with IP_NF_NAT_LOCAL)
Quoted 2 lines
that the why. the proper way to avoid this is to have people on the inside connect to 192.168.10.10.
Quoted 29 lines · Jason Opperisano
Quoted 10 lines · Payal Rathod
Hi,
I have a rule on my friend's broadband connection to redirect traffic from outside to an internal machine like,iptables -A PREROUTING -d 1.2.3.4 -p tcp -m tcp --dport 80 -j DNAT \
--to-destination 192.168.10.10:80But she complained that people from inside the network cannot do
http://1.2.3.4 in their browser and see the site. Is she correct? What is wrong with my rule because I can see the site from outside?1) client; say 192.168.10.100, sends TCP SYN to 1.2.3.4
2) iptables machine receives packet destined for 1.2.3.4, DNAT's it to 192.168.10.10 and forwards the packet out the internal interface
3) 192.168.10.10 receives TCP SYN from 192.168.10.100 and replies
directly to 192.168.10.100 with a SYN/ACK4) client; 192.168.10.100, receives SYN/ACK from 192.168.10.10 and discards it, as it matches no connection in the
SYN_SENTstate (recall that our SYN was sent to 1.2.3.4).that the why. the proper way to avoid this is to have people on the inside connect to 192.168.10.10. i will leave all the half-assed work-arounds and kludges as an exercise for the reader and other posters.
Quoted 8 lines
-j
--
"Peter: This party couldn't be better if Jesus was here.
Jesus: For my next miracle, I will turn water... into FUNK."
--Family Guy
Because the destination server is on the same subnet, users on the inside could indeed connect directly to that machine. Alternatively this could be handled via DNS.
However, if the destination server is inside a DMZ, the firewall needs to DNAT in
PREROUTING and SNAT in POSTROUTING. The DNAT gets traffic to the DMZ, the SNAT allows it back. Something like:
iptables --table nat -A PREROUTING -p tcp -i $LAN_INTERFACE --dport http \
-d $INTERNET_IP -j DNAT --to-destination $DMZ_HTTP_IP
iptables --table nat -A POSTROUTING -d $DMZ_HTTP_IP -s $LAN_IP_RANGE \
-p tcp --dport http -j SNAT --to-source $LAN_IPQuoted 9 lines · Donald Murray
Because the destination server is on the same subnet, users on the inside could indeed connect directly to that machine. Alternatively this could be handled via DNS.
However, if the destination server is inside a DMZ, the firewall needs to DNAT in
PREROUTING and SNAT in POSTROUTING. The DNAT gets traffic to the DMZ, the SNAT allows it back. Something like:
no--it doesn't. if by "the destination server is inside a DMZ" you mean the web server is on a different layer3 subnet than the client, routed through the firewall. you are applying the half-assed SNAT solution where it's not even needed. this is worse than the SNAT for the OP's scenario; at least there the SNAT serves to create some semblance of functionality.
NAT is the duct tape of networking; if you can route, route.
-j
--
"Peter: I'm going to microwave a bagel and have sex with it.
Quagmire: Butter's in the fridge."
--Family Guy
Quoted 10 lines · Payal Rathod
Hi,
I have a rule on my friend's broadband connection to redirect traffic from outside to an internal machine like,iptables -A PREROUTING -d 1.2.3.4 -p tcp -m tcp --dport 80 -j DNAT \
--to-destination 192.168.10.10:80But she complained that people from inside the network cannot do
http://1.2.3.4 in their browser and see the site. Is she correct? What is wrong with my rule because I can see the site from outside?
The problem is only the initial SYN will go through the expected route.
1) Client 192.168.10.53 > Server 1.2.3.4
2) Router 192.168.10.1 DNATs packet to 192.168.10.10
3) Server 192.168.10.10 sees request from 192.168.10.53
4) Server sends response to 192.168.10.53
5) Client expects response from 1.2.3.4, receives from 192.168.10.10, drops it
Instead you want
1) Client 192.168.10.53 > Server 1.2.3.4
2) Router DNATs packet to 192.168.10.10, SNATs packet to 192.168.10.1
3) Server sees request from 192.168.10.1
4) Server sends response to 192.168.10.1
5) Router uses SNAT to relay response to 192.168.10.53
5) Client gets expected response from 1.2.3.4
See here for implementation details:
http://netfilter.org/documentation/HOWTO//NAT-HOWTO-10.html
On 7/14/05, curby . <[email protected]> wrote:
[snip]
Quoted 2 lines
See here for implementation details:
http://netfilter.org/documentation/HOWTO//NAT-HOWTO-10.html
Boy, how embarassing. This has already been discussed to death. =P
Re: DNAT+SNAT vs DNS: depends on your network. It's been mentioned that some people don't even have a DNS server...