Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
12-06-2004, 06:01 PM
|
#1
|
Member
Registered: Jun 2002
Distribution: RH, FC, FreeBSD,OpenBSD
Posts: 326
Rep:
|
IPTables on a RH3 box
Evening everyone.
Working on learning IPTables here. But I have a quick question.
I need to setup IPTables on a RH box that is inside our private network. It is a pretty important system, so security needs to be very tight.
With that in mind, what i wanted to do was setup IPTables on the box to only allow access to certain ports from certain IP addresses. Also, I do not need to do any sort of NAT our routing on the box. The only thing I need to do is allow access to the box on certain ports from a specific network range.
Should not be to terrible I am guessing. Im hoping at least.
My main question is on the outbound traffic. It will only need to leave outbound, via port 80 (does web checks on a vendors site) and im also guessing the port for RHN.
With that in mind, can I pretty much just setup some rules to just allow what I want, and deny everything else?
Never really worked with iPtables before. Have a lot of experience with PF and IPF/IPFW.
Anyway, just wanted to get some feedback from people with more experience.
Cheers,
Tarballed
|
|
|
12-06-2004, 06:22 PM
|
#2
|
Member
Registered: Nov 2004
Location: Brisbane, Australia
Distribution: Fedora Core 5
Posts: 89
Rep:
|
tarballed,
You need something like this, where all packets a explicitly dropped, then only allow the selective packets that are needed.
Code:
#!/bin/sh
#
# Firewall Script
### Remove all previous rules, and delete any user defined chains
iptables -F
iptables -X
### Set the default policies to drop
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
### Loopback device OK
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
###############################################################
### OUTBOUND Rule: Allow ALL packets out the external device
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
### OUTBOUND Rule: Allow ONLY NEW packets on these ports.
# (After NEW connection is established, the above rule allows all following packets)
iptables -A OUTPUT -m state --state NEW -m tcp -p tcp --syn --dport 80 -j ACCEPT
###############################################################
### INBOUND Rule: Allow ALL packets if a connection already exists
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
### INBOUND Rule: Allow ONLY NEW packets on these ports.
# (After NEW connection is established, the above rule allows all following packets)
iptables -A INPUT -s 192.168.1.25 -m state --state NEW -m tcp -p tcp --syn --dport 80 -j ACCEPT
iptables -A INPUT -s 192.168.1.26 -m state --state NEW -m tcp -p tcp --syn --dport 80 -j ACCEPT
You will need to adjust the inbound and outbound rules to suit your requirements.
If you need more info on firewall concepts, I've drafted this: http://www.brennan.id.au/06-Firewall_Concepts.html
Hope it helps..
BU
|
|
|
12-06-2004, 06:24 PM
|
#3
|
Member
Registered: Jun 2002
Distribution: RH, FC, FreeBSD,OpenBSD
Posts: 326
Original Poster
Rep:
|
Thanks bu!!
That's great. I really appreciate your help, script and the link!
Cheers,
tarballed
|
|
|
12-06-2004, 06:27 PM
|
#4
|
Member
Registered: Nov 2004
Location: Brisbane, Australia
Distribution: Fedora Core 5
Posts: 89
Rep:
|
No probs,
You'll notice the script is similar to the one on the link, I just removed the different interfaces out to suit your needs.
Quick and easy, but you need to test it.
BU.
|
|
|
12-06-2004, 07:11 PM
|
#5
|
Member
Registered: Jun 2002
Distribution: RH, FC, FreeBSD,OpenBSD
Posts: 326
Original Poster
Rep:
|
One last questoin:
Can I build these rules remotely? Or do I have to be at the terminal?
Playing around, I keep locking myself out.
I appreciate it.
|
|
|
12-06-2004, 10:24 PM
|
#6
|
Member
Registered: Nov 2004
Location: Brisbane, Australia
Distribution: Fedora Core 5
Posts: 89
Rep:
|
Yes you can do all your rules remotely.
But if you put the wrong rule in you might get locked out, then you'll need to access the terminal
BU.
|
|
|
All times are GMT -5. The time now is 08:42 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|