Skip to content

iptables rules 4 samba sharing

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
    /etc/sysconfig/iptables

    with your favourite editor as root.

  2. add the following set of rules to the file
  3.  
    # samba stuff
    -A INPUT -p tcp -s 192.168.1.0/24 --dport 139 -j ACCEPT
    -A INPUT -p udp -s 192.168.1.0/24 --dport 139 -j ACCEPT
    -A INPUT -p udp -s 192.168.1.0/24 --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 192.168.1.0/24 --dport 139 -j ACCEPT
    -A OUTPUT -p udp -s 192.168.1.0/24 --dport 139 -j ACCEPT
    -A OUTPUT -p udp -s 192.168.1.0/24 --dport 138 -j ACCEPT
    
  4. restart iptables by doing:
    /etc/init.d/iptables restart

    and you are done.

Change 192.168.1.0/24 to match your own network.

Advertisements

Hello world!

Well here we are! Another blog on the air.
Keep visiting here. Although you may sometimes feel disappointed!