?
Solved

Iptables: Firewall+NAT and server with public

Posted on 2003-10-28
5
Medium Priority
?
569 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 375 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

When ransomware hits your clients, what do you do?

MSPs: Endpoint security isn’t enough to prevent ransomware.
As the impact and severity of crypto ransomware attacks has grown, Webroot has fought back, not just by building a next-gen endpoint solution capable of preventing ransomware attacks but also by being a thought leader.

Question has a verified solution.

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

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
During and after that shift to cloud, one area that still poses a struggle for many organizations is what to do with their department file shares.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

764 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