Solved

Iptables: Firewall+NAT and server with public

Posted on 2003-10-28
5
562 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Identify bottom to remote server 2 32
P2P and MPLS 3 44
Cannot browse to favorite website apologeticspress.org but friends can 20 33
2 Gateways (bandwidth) - One domain 7 53
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).
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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…
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…

920 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

13 Experts available now in Live!

Get 1:1 Help Now