SlackwareThis Forum is for the discussion of Slackware Linux.
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'v recently built a iptables firewall script, witch will work with slackwares startup system. My friend r3d5pik3 (Security Expert and Coder) says i did a pretty good job making this. So i'm telling the Linux Questions Commutity. Note: the files will work on most all distros.
#!/bin/sh
start() {
echo "predatorwall: Applying Iptables rules now"
/etc/firewall/start.sh
if [ $? -eq 0 ]; then
touch /var/lock/subsys/firewall
fi
}
stop() {
echo "predatorwall: Flushing Iptables rules now"
/etc/firewall/flush.sh
if [ $? -eq 0 ]; then
rm -f /var/lock/subsys/firewall
fi
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
/usr/sbin/iptables -L
;;
*)
echo "Usage: start|stop|restart|status"
esac
exit
start.sh
Code:
#!/bin/sh
#
# predatorwall, writen by predatorfreak. Basic, secure iptables configuration
# Starts Logging, logs: /var/log/messages
iptables -A OUTPUT -j LOG
iptables -A INPUT -j LOG
iptables -A FORWARD -j LOG
# Check for incorrect TCP State flags
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -p tcp --tcp-flags ACK,FIN FIN -j DROP
iptables -A INPUT -p tcp --tcp-flags ACK,PSH PSH -j DROP
iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A INPUT -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
# Check for incorrect TCP State flags
iptables -A OUTPUT -p tcp --tcp-flags ALL NONE -j DROP
iptables -A OUTPUT -p tcp --tcp-flags ACK,FIN FIN -j DROP
iptables -A OUTPUT -p tcp --tcp-flags ACK,PSH PSH -j DROP
iptables -A OUTPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
iptables -A OUTPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A OUTPUT -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
# drops incoming packets, the next section allows us to connect
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
# Allows accsess to the loopback interface
iptables -A OUTPUT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -s 127.0.0.0/8 -d 127.0.0.0/8 -i lo -j ACCEPT
# allows SSH connections to come in, if you run a web server/shell server this is usefull, otherwise leave it commented out
# iptables -A INPUT --dport 22 -j ACCEPT
# below is stuff for web servers/shell servers, normal people can leave it commented out
# iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# iptables -A INPUT -p tcp --dport 53 -j ACCEPT
# iptables -A INPUT -p tcp --dport 21 -j ACCEPT
# iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# iptables -A INPUT -p tcp --dport 110 -j ACCEPT
# iptables -A INPUT -p tcp --dport 25 -j ACCEPT
# iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# The Above entrys are for web server things, like smtp and pop3 (25 and 110)
# Script End
Anyone tested predatorwall on connections like Cable or Dail Up? i'd like some feedback on how it works on other configurations and other connections. So i can better improve it .
predator.hawk aka predatorfreak
Edit: to tangle: np just doing my job , also just so ya know. flush.sh and start.sh go in /etc/firewall (you may have to make this directory).
Last edited by predator.hawk; 10-15-2004 at 02:53 PM.
Also here are my rules to allows access to the loopback interface :
iptables -A INPUT -i lo -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT
iptables -A OUTPUT -o lo -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT
I suspect your line :
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
may accept connection that not come from localhost
And enable rule for passive ftp is not too much :
iptables -A INPUT -i eth0 -p tcp --sport 1024: --dport 1024: \
-m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 1024: --dport 1024: \
-m state --state ESTABLISHED,RELATED -j ACCEPT
This ftp rule works with the ip_conntrack_ftp kernel option so it need to be loaded before if compiled as module
if ! grep ip_conntrack_ftp /proc/modules 1> /dev/null ; then
/sbin/modprobe ip_conntrack_ftp
fi
Getting Ready To Release Predatorwall v0.2 right now, i added the Suggested commands and added Basic /proc security. Also I prefer to log all connections, thus if something slips by i know it does and i can fix it . Proble around v0.4 i'l just be logging droped connections. But in early development its more of a debugging feature .
position your cursor on the hour field, then type 'a', enter your new hour no matter
where the old hour is at this time. Once new hour entered press <esc> key
and position the cursor on the char you want to delete, then type 'x' to
delete the char
save and quit : press <esc> then type ':' then type 'wq', then press enter
That is
Or just do 'logrotate' as root at the command line to rotate log by hand
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.