Skip to content

iptables rules 4 samba sharing

September 10, 2011

Hello all!
Today i’m sharing a set of rules to setup an iptables firewall on a linux box (fedora) for samba.
If you ever have setup a samba daemon on your network you probably also thought about security accessing it, bellow you can see a set of rules for samba/share/access on your local network:

  1. start by accessing

    with your favourite editor as root.

  2. add the following set of rules to the file
    # samba stuff
    -A INPUT -p tcp -s --dport 139 -j ACCEPT
    -A INPUT -p udp -s --dport 139 -j ACCEPT
    -A INPUT -p udp -s --dport 138 -j ACCEPT
    -A INPUT -p tcp -s 0/0 --dport 139 -j DROP
    -A INPUT -p udp -s 0/0 --dport 139 -j DROP
    -A INPUT -p udp -s 0/0 --dport 138 -j DROP
    -A INPUT -p udp -s 0/0 --dport 137 -j DROP
    -A OUTPUT -p tcp -s --dport 139 -j ACCEPT
    -A OUTPUT -p udp -s --dport 139 -j ACCEPT
    -A OUTPUT -p udp -s --dport 138 -j ACCEPT
  4. restart iptables by doing:
    /etc/init.d/iptables restart

    and you are done.

Change to match your own network.

From → firewall, iptables, linux

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: