LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-13-2008, 11:21 AM   #1
n3uro
LQ Newbie
 
Registered: Dec 2008
Posts: 7

Rep: Reputation: 0
Slackware 11, firewall


Using this rules:

Code:
#!/bin/sh

# Begin /bin/firewall-start

# Insert connection-tracking modules (not needed if built into the kernel).
modprobe ip_tables
modprobe iptable_filter
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ipt_state
modprobe ipt_LOG

# allow full access only to 10.108.147.3
#iptables -A INPUT -i eth0 -s 10.108.147.3 -j ACCEPT


# allow everything only for port 80
iptables -A INPUT -p tcp --dport 80 -j ACCEPT

# anti-flooding modul
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s --limit-burst 10 -j ACCEPT

# free output on any interface to any ip for any service
# (equal to -P ACCEPT)
iptables -A OUTPUT -j ACCEPT

# permit answers on already established connections
# and permit new connections related to established ones (eg active-ftp)
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Log everything else: What's Windows' latest exploitable vulnerability?
iptables -A INPUT -j LOG --log-prefix "FIREWALL:INPUT "

# set a sane policy: everything not accepted > /dev/null
#iptables -P INPUT DROP
#iptables -P FORWARD DROP
#iptables -P OUTPUT DROP

# be verbose on dynamic ip-addresses (not needed in case of static IP)
echo 2 > /proc/sys/net/ipv4/ip_dynaddr

# disable ExplicitCongestionNotification - too many routers are still
# ignorant
echo 0 > /proc/sys/net/ipv4/tcp_ecn

# If you are frequently accessing ftp-servers or enjoy chatting you might
# notice certain delays because some implementations of these daemons have
# the feature of querying an identd on your box for your username for
# logging. Although there's really no harm in this, having an identd
# running is not recommended because some implementations are known to be
# vulnerable.
# To avoid these delays you could reject the requests with a 'tcp-reset':
#iptables -A INPUT -p tcp --dport 113 -j REJECT --reject-with tcp-reset
#iptables -A OUTPUT -p tcp --sport 113 -m state --state RELATED -j ACCEPT

# To log and drop invalid packets, mostly harmless packets that came in
# after netfilter's timeout, sometimes scans:
#iptables -I INPUT 1 -p tcp -m state --state INVALID -j LOG --log-prefix \ "FIREWALL:INVALID"
#iptables -I INPUT 2 -p tcp -m state --state INVALID -j DROP

# End /bin/firewall-start
Need set just one open port (80) for incoming connections but
Code:
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
not working.
Can somebody check that rules and fix my mistakes?

EDIT:

And need port for samba for lan ip

Last edited by n3uro; 12-13-2008 at 11:24 AM.
 
Old 12-14-2008, 09:31 AM   #2
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
I added the following section to your existing script:

Code:
# Clear the existing firewall rules

iptables -P INPUT DROP          # Set default policy to DROP
iptables -P FORWARD DROP        # Set default policy to DROP
iptables -P OUTPUT DROP         # Set default policy to DROP
iptables -F                     # Flush all chains
iptables -X                     # Delete all userchains

for table in filter nat mangle
do
        iptables -t $table -F   # Delete the table's rules
        iptables -t $table -X   # Delete the table's chains
        iptables -t $table -Z   # Zero the table's counters
done
Here is the modified script:

Code:
#!/bin/sh

# Begin /bin/firewall-start

# Insert connection-tracking modules (not needed if built into the kernel).
modprobe ip_tables
modprobe iptable_filter
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ipt_state
modprobe ipt_LOG

# Clear the existing firewall rules

iptables -P INPUT DROP          # Set default policy to DROP
iptables -P FORWARD DROP        # Set default policy to DROP
iptables -P OUTPUT DROP         # Set default policy to DROP
iptables -F                     # Flush all chains
iptables -X                     # Delete all userchains

for table in filter nat mangle
do
        iptables -t $table -F   # Delete the table's rules
        iptables -t $table -X   # Delete the table's chains
        iptables -t $table -Z   # Zero the table's counters
done

# allow full access only to 10.108.147.3
#iptables -A INPUT -i eth0 -s 10.108.147.3 -j ACCEPT


# allow everything only for port 80
iptables -A INPUT -p tcp --dport 80 -j ACCEPT

# anti-flooding modul
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s --limit-burst 10 -j ACCEPT

# free output on any interface to any ip for any service
# (equal to -P ACCEPT)
iptables -A OUTPUT -j ACCEPT

# permit answers on already established connections
# and permit new connections related to established ones (eg active-ftp)
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Log everything else: What's Windows' latest exploitable vulnerability?
iptables -A INPUT -j LOG --log-prefix "FIREWALL:INPUT "

# set a sane policy: everything not accepted > /dev/null
#iptables -P INPUT DROP
#iptables -P FORWARD DROP
#iptables -P OUTPUT DROP

# be verbose on dynamic ip-addresses (not needed in case of static IP)
echo 2 > /proc/sys/net/ipv4/ip_dynaddr

# disable ExplicitCongestionNotification - too many routers are still
# ignorant
echo 0 > /proc/sys/net/ipv4/tcp_ecn

# If you are frequently accessing ftp-servers or enjoy chatting you might
# notice certain delays because some implementations of these daemons have
# the feature of querying an identd on your box for your username for
# logging. Although there's really no harm in this, having an identd
# running is not recommended because some implementations are known to be
# vulnerable.
# To avoid these delays you could reject the requests with a 'tcp-reset':
#iptables -A INPUT -p tcp --dport 113 -j REJECT --reject-with tcp-reset
#iptables -A OUTPUT -p tcp --sport 113 -m state --state RELATED -j ACCEPT

# To log and drop invalid packets, mostly harmless packets that came in
# after netfilter's timeout, sometimes scans:
#iptables -I INPUT 1 -p tcp -m state --state INVALID -j LOG --log-prefix \ "FIREWALL:INVALID"
#iptables -I INPUT 2 -p tcp -m state --state INVALID -j DROP

# End /bin/firewall-start
Try this and see if it does what you are looking for.

Regards,
Fordeck
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rc.firewall on slackware 11.0 soylentgreen Linux - Networking 4 05-07-2007 06:55 PM
Firewall in Slackware 10.0 nickbird Linux - Newbie 2 07-29-2004 04:52 PM
The best firewall for Slackware? Smaugur [SWE] Linux - Security 5 03-31-2004 05:25 AM
Firewall on Slackware ? jamaso Linux - General 11 01-30-2002 11:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration