WTF *Nix

Just another *nix Blog

Samba and IPTables Firewall Script

Apr-22-2009 By WTF *Nix

Figured to share the following IPTables bash script with everyone that requires information on how to allow access through your IPTables to your local network with Samba:

#!/bin/bash

SAMBA_SERVER=”192.168.0.1 ”
NETWORK=”192.168.0.0/24″
BROADCAST=”192.168.255.255″

iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -p udp -s $NETWORK -d $SAMBA_SERVER -m multiport –dports 137,138 -j ACCEPT
iptables -A INPUT -p tcp -s $NETWORK -d $SAMBA_SERVER -m multiport –dports 139,445 -j ACCEPT
iptables -A INPUT -p udp -s $NETWORK -d $BROADCAST –dport 137 -j ACCEPT
iptables -A INPUT -p udp -d $SAMBA_SERVER -m multiport –dports 137,138 -j DROP
iptables -A INPUT -p tcp -d $SAMBA_SERVER -m multiport –dports 139,445 -j DROP
iptables -A OUTPUT -s $SAMBA_SERVER -d $NETWORK -m state –state ESTABLISHED,RELATED -j ACCEPT

Share and Enjoy:
  • Google Bookmarks
  • MySpace
  • Facebook
  • StumbleUpon
  • Print
  • email
  • Digg

Comments are closed.