Solved

Iptables: Firewall+NAT and server with public

Posted on 2003-10-28
5
564 Views
Last Modified: 2013-11-16
Hi,

I am setting up firewall with linux box(RH9). I have ten computers that should be behind NAT and one with public ip(should be also behind that firewall).  I am a newbie with iptables. :/

SO the case is this: internet----(public ip:ETH0)linux(private ip:ETH1)-----computers with private ip's and server with public ip.
I want SSH to be only access to linux box from internet. I don't know yet what ports that server use but lets say that its a web server.  

Does anybody has example of config?? Everything helps...please help!

-Repsu
0
Comment
Question by:Repsu
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:_tack
ID: 9641091
the config must be as follow:

All machines behind the firewall need to have private IP (let's say 172.16.1.x)

# Masquerade all hosts
/sbin/iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

# forward incoming web requests to web server (IP address of server is 172.16.1.25)
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 80 --syn -i ppp0 -j DNAT --to 172.16.1.25

These are the really basic rules, you might then want to make your firewall more secure, by changing the
default policy for PREROUTING from ACCEPT to DROP, then you will have to add

/sbin/iptables -t nat -P PREROUTING DROP
/sbin/iptables -t nat -A PREROUTING -m state --state RELATED,ESTABLISHED -j ACCEPT

Have a look at this very nice iptables tutorial:
http://iptables-tutorial.frozentux.net/iptables-tutorial.html
0
 
LVL 3

Accepted Solution

by:
_tack earned 125 total points
ID: 9641119
to close access to your firewall:

# accept traffic coming from eth0 on port 22 only, other traffic is dropped (accept also reply to our requests)
/sbin/iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
/sbin/iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A INPUT -i eth0 -j DROP
0
 

Author Comment

by:Repsu
ID: 9648080
Thanks for the link and examples. If i but one more NIC in my firewall, can i use forward to my server then and use public ip??? If it's possible, how do i od that?
0
 
LVL 3

Expert Comment

by:_tack
ID: 9648212
From a networking point of view, NO.
If you only have one public IP address, you cannot build a "DMZ", you need at least 4, in order to create a subnet.
(1 for Subnet, 1 for Broadcast, 2 for hosts - firewall, server).
From the security point of view this limitation is not that bad, since you will have to configure your firewall
to forward traffic to your server --- you expose only services you explicitly forward, others are hidden, and your
server is more protect.

Linux has a workaround to this limitation, Linux can be configured to behave like a bridge, and there is a patch
that will allow you to build a "firewalled" bridge.

To do this, you need to build a new kernel, if you are interested in this, I can post here some links, but you will have
to build a new kernel and configure the bridging software.
0
 

Author Comment

by:Repsu
ID: 9648473
I try to talk to my "boss" and i hope i can drop that server behind my firewall. It isn't even mine! :)
Thanks for your help!!!


0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Even if you have implemented a Mobile Device Management solution company wide, it is a good idea to make sure you are taking into account all of the major risks to your electronic protected health information (ePHI).
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question