[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Iptables: Firewall+NAT and server with public

Posted on 2003-10-28
5
Medium Priority
?
570 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

I had an issue with InstallShield not being able to use Computer Browser service on Windows Server 2012. Here is the solution I found.
This program is used to assist in finding and resolving common problems with wireless connections.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
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

649 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