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.
I haven't used iptables in quite some time now and just made an iptables script. This script was designed for a home network. Is there anything else I can do to beef up this script? I've spent a lot of time reading about iptables ( seems to be an endless journey ). Any thoughts would be appreciated.
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
# iptables v1.2.10 #
# Firewall script to keep those unwanted attackers out of #
# my box... hopefully! #
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
# Make default policies...
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
# Allow loopback...
iptables -A INPUT -i lo -j ACCEPT
# Allow UDP port 53...
iptables -A INPUT -i eth0 -p udp --sport 53 -s 192.168.0.1/255.255.255.0 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Add some TCP INPUT rules...
iptables -A INPUT -i eth0 -s 192.168.0.101/255.255.255.0 -d 0/0 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i eth0 -p tcp -s 0/0 -d 0/0 --dport 22 -j ACCEPT
# Drop those nasty packets...
iptables -A INPUT -i eth0 -p ALL -m state --state INVALID -j DROP
iptables -A INPUT -i eth0 -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
iptables -A INPUT -i eth0 -p tcp --tcp-flags ALL ALL -j DROP
iptables -A INPUT -i eth0 -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
iptables -A INPUT -i eth0 -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -i eth0 -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A INPUT -i eth0 -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
I am no IPTables expert, but I have been reading a lot lately on the subject in prepartion for numerous projects.
i would ask the following;
Do you have any hosts behind this box that need to go outbound?
I see you are accepting SSH connection. I would say, if you can, put the Source IP from the ssh originating connection, if possible. That would give you more protection.
Personally, I would drop the bad stuff before I started accepting anything. I know that means more rules to traverse, but the way you've got it written, the nasty packet rules aren't doing anything since there are no ACCEPT rules after them.
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
# iptables v1.2.10 #
# Firewall script to keep those unwanted attackers out of #
# my box... hopefully! #
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
# Flush any existing rules...
iptables -F
# Make default policies...
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
# Drop those nasty packets...
iptables -A INPUT -i eth0 -p ALL -m state --state INVALID -j DROP
iptables -A INPUT -i eth0 -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
iptables -A INPUT -i eth0 -p tcp --tcp-flags ALL ALL -j DROP
iptables -A INPUT -i eth0 -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
iptables -A INPUT -i eth0 -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -i eth0 -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A INPUT -i eth0 -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
# Allow loopback...
iptables -A INPUT -i lo -j ACCEPT
# Allow UDP port 68...
iptables -A INPUT -i eth0 -p udp --sport 68 -s 192.168.0.1/255.255.255.0 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Add some TCP INPUT rules...
iptables -A INPUT -i eth0 -s 192.168.0.101/255.255.255.0 -d 0/0 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i eth0 -p tcp -s 0/0 -d 0/0 --dport 22 -j ACCEPT
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.