Port forwarding.
Hi all.
I'm trying to setup a firewall/port forwarder but can't get things going. Some facts:
LAN is my internal network and WAN is external.
I have a static ip# on WAN and LAN.
Access to SSH on firewall works.
IP Forwarding and NAT from LAN to WAN works :-)
The problem:
On my LAN i have another machine with web, mail, ftp-server(192.168.0.100) witch have to be accessible from the WAN.
But I just cant get it working.
Question:
At http://iptables-tutorial.frozentux.net/iptables-tutorial.html#DNATTARGET
(Oskar Andreasson) says
Quote
"This last rule will seriously harm your logging, so it is really advisable not to use this method, but the whole example is still a valid one for all of those who can't afford to set up a specific DMZ or alike. What will happen is this, packet comes from the Internet, gets SNAT'ed and DNAT'ed, and finally hits the HTTP server (for example). The HTTP server now only sees the request as if it was coming from the firewall, and hence logs all requests from the internet as if they came from the firewall." End quote.
Is there some way to do this so the logging sees the "right" IP# ???
Regards Gunnar Frödin (Sweden)
One more thing: I'm trying all this out with WMware(www.vmware.com/), Virtual Machine Software, but I havent read anything about some limitations with that.
# DNAT/SNAT Port Forwarding
# this is the prerouting dnat iptables -A PREROUTING -t nat -p tcp -d 217.215.x.x --dport 25 -j DNAT --to-destination 192.168.0.100:25 # This allows packets from external->internal iptables -A FORWARD -p tcp -i eth0 -o eth1 -d 192.168.0.100 --dport 25 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT # This allows packets from internal->external iptables -A FORWARD -p tcp -i eth1 -o eth0 -s 192.168.0.100 --sport 25 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT # This enables access to the 'public' server from the internal network iptables -A POSTROUTING -t nat -p tcp -d 192.168.0.100 -s 192.168.0.0/24 --dport 25 -j SNAT --to-source 192.168.0.100:25
Quoted 13 lines · Gunnar Frödin
Hi all.
I'm trying to setup a firewall/port forwarder but can't get things going. Some facts:
LAN is my internal network and WAN is external.
I have a static ip# on WAN and LAN.
Access to SSH on firewall works.
IP Forwarding and NAT from LAN to WAN works :-)The problem:
On my LAN i have another machine with web, mail, ftp-server(192.168.0.100) witch have to be accessible from the WAN.
But I just cant get it working.
Quoted 13 lines
Question:
At http://iptables-tutorial.frozentux.net/iptables-tutorial.html#DNATTARGET
(Oskar Andreasson) says
Quote
"This last rule will seriously harm your logging, so it is really advisable not to use this method, but the whole example is still a valid one for all of those who can't afford to set up a specific DMZ or alike. What will happen is this, packet comes from the Internet, gets SNAT'ed and DNAT'ed, and finally hits the HTTP server (for example). The HTTP server now only sees the request as if it was coming from the firewall, and hence logs all requests from the internet as if they came from the firewall." End quote.
Is there some way to do this so the logging sees the "right" IP# ???
Sure - just don't do the SNAT rule which makes the packets look like they came from the firewall.
The only reason why you would need to add SNAT is to make the server accessible to people both outside and *inside* your network, by using the public IP address.
The recommended way to do it (which is far simpler, and results in the correct IP addresses going into the log files) is to use split DNS, so people on the outside see the public IP, and people on the inside see the private IP, then the routing just works normally.
Regards,
Antony.
Signature · 10 lines
In science, one tries to tell people
in such a way as to be understood by everyone
something that no-one ever knew before.
In poetry, it is the exact opposite.
- Paul Dirac
Please reply to the list;
please don't CC me.Ok about the splitt DNS, i'm new at this(Linux) but I think I know, but if you have the time, some more info would be god, there is a DNS on 192.168.0.100
The real problem is that the port forwarding dose not work at all !!!
//Gunnar
Quoted 8 lines · Gunnar Frödin
Hi all.
I'm trying to setup a firewall/port forwarder but can't get things going. Some facts:
LAN is my internal network and WAN is external.
I have a static ip# on WAN and LAN.
Access to SSH on firewall works.
IP Forwarding and NAT from LAN to WAN works :-)
Quoted 7 lines
The problem:
On my LAN i have another machine with web, mail, ftp-server(192.168.0.100) witch have to be accessible from the WAN.
But I just cant get it working.Question:
At
http://iptables-tutorial.frozentux.net/iptables-tutorial.html#DNATTARGET
Quoted 3 lines
(Oskar Andreasson) says
Quote
"This last rule will seriously harm your logging, so it is really
advisable
Quoted 8 lines
not to use this method, but the whole example is still a valid one for all of those who can't afford to set up a specific DMZ or alike. What will happen is this, packet comes from the Internet, gets SNAT'ed and DNAT'ed, and finally hits the HTTP server (for example). The HTTP server now only sees the request as if it was coming from the firewall, and hence logs all requests from the internet as if they came from the firewall." End quote.
Is there some way to do this so the logging sees the "right" IP# ???
Sure - just don't do the SNAT rule which makes the packets look like they came
from the firewall.
The only reason why you would need to add SNAT is to make the server accessible to people both outside and *inside* your network, by using the public IP address.
The recommended way to do it (which is far simpler, and results in the correct
IP addresses going into the log files) is to use split DNS, so people on the outside see the public IP, and people on the inside see the private IP, then the routing just works normally.
Regards,
Antony.
--
In science, one tries to tell people
in such a way as to be understood by everyone
something that no-one ever knew before.
In poetry, it is the exact opposite.
- Paul Dirac
Please reply to the
list;
please don't CC
me.
Quoted 3 lines · Gunnar Frödin
Ok about the splitt DNS, i'm new at this(Linux) but I think I know, but if you have the time, some more info would be god, there is a DNS on 192.168.0.100
Is that DNS server providing responses to internal clients only, or to external clients as well (in which case, how have you done the DNAT rules for that one!?)
Quoted 1 line
The real problem is that the port forwarding dose not work at all !!!
What, not even from the outside? Hm. The ruleset you posted looked
sensible enough.
Two questions then:
1. Is the public address 217.215.x.x which you are using as the original destination in your DNAT rule bound to the external interface (eth0) of the firewall?
2. What do the packet counts for the appropriate rules show from "iptables -L FORWARD -nvx; iptables -L PREROUTING -t nat -nvx"?
The packet counts should show us whether packets are:
a) arriving
b) getting DNATted
c) being FORWARDed
d) getting replies
Regards,
Antony.
Signature · 4 lines
Ramdisk is not an installation procedure.
Please reply to the list;
please don't CC me.Lets wait with the dns config for a moment ok?
Answer to question 1: YES
Answer to question 2:
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source
destination
6 360 ACCEPT tcp -- eth0 eth1 0.0.0.0/0
192.168.0.100 tcp dpt:25 state NEW,RELATED,ESTABLISHED
0 0 ACCEPT tcp -- eth1 eth0 192.168.0.1000.0.0.0/0 tcp spt:25 state NEW,RELATED,ESTABLISHED
Chain PREROUTING (policy ACCEPT 20 packets, 2796 bytes)
pkts bytes target prot opt in out source
destination
1 60 DNAT tcp -- * * 0.0.0.0/0
10.20.30.40 tcp dpt:25 to:192.168.0.100:25
I tryed to telnet in, witch times-out after 6 attempts
Quoted 3 lines · Gunnar Frödin
Ok about the splitt DNS, i'm new at this(Linux) but I think I know, but if you have the time, some more info would be god, there is a DNS on 192.168.0.100
Is that DNS server providing responses to internal clients only, or to external clients as well (in which case, how have you done the DNAT rules for
that one!?)
Quoted 1 line
The real problem is that the port forwarding dose not work at all !!!
What, not even from the outside? Hm. The ruleset you posted looked
sensible enough.
Two questions then:
1. Is the public address 217.215.x.x which you are using as the original destination in your DNAT rule bound to the external interface (eth0) of the firewall?
2. What do the packet counts for the appropriate rules show from "iptables -L
FORWARD -nvx; iptables -L PREROUTING -t nat -nvx"?
The packet counts should show us whether packets are:
a) arriving
b) getting DNATted
c) being FORWARDed
d) getting replies
Regards,
Antony.
--
Ramdisk is not an installation procedure.
Please reply to the
list;
please don't CC
me.
Quoted 5 lines · Gunnar Frödin
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source
destination6 360 ACCEPT tcp -- eth0 eth1 0.0.0.0/0192.168.0.100 tcp dpt:25 state NEW,RELATED,ESTABLISHED
Okay, so we *are* seeing packets to the mail server being forwarded through the firewall.
Quoted 2 lines
0 0 ACCEPT tcp -- eth1 eth0 192.168.0.1000.0.0.0/0 tcp spt:25 state NEW,RELATED,ESTABLISHED
But we are not seeing any replies coming back.
Quoted 5 lines
Chain PREROUTING (policy ACCEPT 20 packets, 2796 bytes)
pkts bytes target prot opt in out source
destination1 60 DNAT tcp -- * * 0.0.0.0/010.20.30.40 tcp dpt:25 to:192.168.0.100:25
And, indeed, the DNAT is working (not surprising, since we saw forwarded packets).
Quoted 1 line
I tryed to telnet in, witch times-out after 6 attempts
The 6 packets we can see in the FORWARD rule above :)
Okay, three more questions:
1. Is a mail server running on 192.168.0.100 (!) ? Can you telnet to it on
the real 192.168.0.100 address from a local client?
2. Are there any access controls on the mail server, restricting the IPs from which it will accept connections?
3. Does the default route of the mail server point back to the firewall?
Regards,
Antony
Signature · 6 lines
Software development can be quick, high quality, or low cost.
The customer gets to pick any two out of three.
Please reply to the list;
please don't CC me.Okey it works now........
The fault was in question 3.
the mail server pointed at another router/firewall.
and the mail server reported the "external" ip# in response to a smtp helo command. nice :-) but as I understan it shound't well well.
Thanks for now Antony.
Regards Gunnar
Okay, three more questions:
1. Is a mail server running on 192.168.0.100 (!) ? Can you telnet to it on
the real 192.168.0.100 address from a local client?
2. Are there any access controls on the mail server, restricting the IPs from
which it will accept connections?
3. Does the default route of the mail server point back to the firewall?
Regards,
Antony
--
Software development can be quick, high quality, or low cost.
The customer gets to pick any two out of three.
Please reply to the
list;
please don't CC
me.