Justin Morgan
07-24-2004, 08:49 PM
Please help! I've tried reading the IPTABLES man page and scoured Google,
but with no luck. I'm having trouble getting port forwarding to work...I'd
like requests that come in to my firewall on port 80 to be forwarded to the
private web host on port 8080.
I'm certain that two or three extra lines in /etc/sysconfig/iptables will
enable the functionality, but I've been unable to find the magic
incantations.
I have a pretty generic home office configuration. I'm running Red Hat 8
and iptables on the firewall. The firewall has its own static IP address on
an external Internet ethernet interface. It also has an internal interface
to the private non-routable network (10.x.x.x). I'm using Network Address
Translation to mask the private hosts behind the firewall. This is all
working well.
Now I've added a web server to my private network behind the firewall.
Here's an ASCII diagram of the network:
<INTERNET>
|
+--+--+
| DSL |
|modem|
+--+--+
|
external static IP (eth0)
+----+-----+
| Firewall |
| host |
+----+-----+
internal 10.0.0.1 (eth1)
|
+--+--+
| hub |
+--+--+
|
+-----------------+--------- . . .
| |
10.0.0.2 10.0.0.3
+----+-------+ +----+-----+
| Web Server | | Other |
|on port 8080| | machine |
+------------+ +----------+
Here are my current firewall rules from /etc/sysconfig/iptables.
----------------------------------------------------
*filter
# define the user-defined 'firewall' chain
-N firewall
# accept all mail connections on any interface for Sendmail/PostFix
# from any interface
# (note: 'mail' is defined in /etc/services, which iptables accepts)
-A firewall -p tcp -m tcp --dport mail -j ACCEPT
# accept all SSH connections from any interface
-A firewall -p tcp -m tcp --dport ssh -j ACCEPT
# accept all IMAPS connections on any interface (but not IMAP)
-A firewall -p tcp -m tcp --dport imaps -j ACCEPT
# accept all established and related connections from any interface
-A firewall -m state --state ESTABLISHED,RELATED -j ACCEPT
# accept all new connections as long as they are not from eth0
# (ie, accept everything except from the Internet-facing interface)
-A firewall -m state --state NEW -i ! eth0 -j ACCEPT
# block everything else (eg, block the Internet-facing interface)
-A firewall -j DROP
# jump to that chain from the INPUT and FORWARD chains
-A INPUT -j firewall
-A FORWARD -j firewall
COMMIT
*nat
# change source addresses to <my_external_ip_addr>
-A POSTROUTING -o eth0 -j SNAT --to <my_external_ip_addr>
COMMIT
----------------------------------------------------
Many, many thanks for any help!
- Justin
but with no luck. I'm having trouble getting port forwarding to work...I'd
like requests that come in to my firewall on port 80 to be forwarded to the
private web host on port 8080.
I'm certain that two or three extra lines in /etc/sysconfig/iptables will
enable the functionality, but I've been unable to find the magic
incantations.
I have a pretty generic home office configuration. I'm running Red Hat 8
and iptables on the firewall. The firewall has its own static IP address on
an external Internet ethernet interface. It also has an internal interface
to the private non-routable network (10.x.x.x). I'm using Network Address
Translation to mask the private hosts behind the firewall. This is all
working well.
Now I've added a web server to my private network behind the firewall.
Here's an ASCII diagram of the network:
<INTERNET>
|
+--+--+
| DSL |
|modem|
+--+--+
|
external static IP (eth0)
+----+-----+
| Firewall |
| host |
+----+-----+
internal 10.0.0.1 (eth1)
|
+--+--+
| hub |
+--+--+
|
+-----------------+--------- . . .
| |
10.0.0.2 10.0.0.3
+----+-------+ +----+-----+
| Web Server | | Other |
|on port 8080| | machine |
+------------+ +----------+
Here are my current firewall rules from /etc/sysconfig/iptables.
----------------------------------------------------
*filter
# define the user-defined 'firewall' chain
-N firewall
# accept all mail connections on any interface for Sendmail/PostFix
# from any interface
# (note: 'mail' is defined in /etc/services, which iptables accepts)
-A firewall -p tcp -m tcp --dport mail -j ACCEPT
# accept all SSH connections from any interface
-A firewall -p tcp -m tcp --dport ssh -j ACCEPT
# accept all IMAPS connections on any interface (but not IMAP)
-A firewall -p tcp -m tcp --dport imaps -j ACCEPT
# accept all established and related connections from any interface
-A firewall -m state --state ESTABLISHED,RELATED -j ACCEPT
# accept all new connections as long as they are not from eth0
# (ie, accept everything except from the Internet-facing interface)
-A firewall -m state --state NEW -i ! eth0 -j ACCEPT
# block everything else (eg, block the Internet-facing interface)
-A firewall -j DROP
# jump to that chain from the INPUT and FORWARD chains
-A INPUT -j firewall
-A FORWARD -j firewall
COMMIT
*nat
# change source addresses to <my_external_ip_addr>
-A POSTROUTING -o eth0 -j SNAT --to <my_external_ip_addr>
COMMIT
----------------------------------------------------
Many, many thanks for any help!
- Justin