Solved

Iptables: Firewall+NAT and server with public

Posted on 2003-10-28
5
561 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

To setup a SonicWALL for policy based routing to be used with the Websense Content Gateway there are several steps that need to be completed. Below is a rough guide for accomplishing this. One thing of note is this guide is intended to assist in the…
If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now