Linux - SecurityThis 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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.