By Vaibhav.T
i am new in Iptables and trying to write rules for my Samba server.I did some help from internet, created one script and run from rc.local :
#Allow loopback
iptables -I INPUT -i lo -j ACCEPT
# Accept packets from Trusted network
iptables -A INPUT -s my-network/subnet -j ACCEPT
# to allow established session to received traffic
iptables -A INPUT -m conntrack –ctstate ESTABLISHED,RELATED -j ACCEPT
# to allow SSH on port 22 from my network
iptables -A INPUT -i eth0 -p tcp -s my-network/subnet –dport 22 -m state –state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp –sport 22 -m state –state ESTABLISHED -j ACCEPT
# To Allow incoming traffice on default SAMBA PORTS
iptables -A INPUT -p udp –dport 137 -j ACCEPT
iptables -A INPUT -p udp –dport 138 -j ACCEPT
iptables -A INPUT -p udp –dport 139 -j ACCEPT
iptables -A INPUT -p tcp –dport 139 -j ACCEPT
iptables -A INPUT -p tcp –dport 445 -j ACCEPT
#Enable Logging
iptables -A INPUT -j LOG
iptables -A INPUT -m limit –limit 2/min -j LOG –log-prefix “Iptables packet Drop” –log-level 7
# Drop all other Packets
iptables -A INPUT -j DROP
I also created one separate log file for iptables in /var/log/iptables.log and edit /etc/syslog.conf :
*.info;kern!=warning;mail.none;news.none;authpriv.none;cron.none /var/log/message
# Add new location
kern.warning /var/log/iptables.log
But my Drop packets are not showing in iptables.log file.Please let me know if i am doing wrong and let me know the correct way to write.I only want samba communication nothing else.
Thank You
Vaibhav
…read more
Source: FULL ARTICLE at The UNIX and Linux Forums