# Iptables samba block all except 192.168.*

## dayul

Hi, first of all apologies if this is in the forums somewhere, i just haven't been able to find it.

I have my iptables script as follows:

```
#!/bin/bash

IPTABLES='/sbin/iptables'

# Set the default input policy to reject.

$IPTABLES -P INPUT DROP

# Set the forward policy to reject

$IPTABLES -P FORWARD DROP

# Allow traffic on the loopback interface

$IPTABLES -A INPUT -i lo -j ACCEPT

# Allow incoming traffic associated with connections we've initiated

$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allow DHCP responses

$IPTABLES -A INPUT -p udp --destination-port 68 -j ACCEPT

# Allow samba connections

$IPTABLES -A INPUT -p udp --destination-port 137 -j ACCEPT

$IPTABLES -A INPUT -p udp --destination-port 138 -j ACCEPT

$IPTABLES -A INPUT -p tcp --destination-port 139 -j ACCEPT
```

Which works very nicely.  However, for the samba connections instead of accepting all on ports 137/138/139 i want to allow only connections from 192.168.*.*

How can i modify the above to do this?

Many thanks,

Dale

----------

## ronnie

Simply add -s 192.168.0.0/16 to your rules.

----------

## dayul

thanks for the quick reply ronnie, that was exactly what i wanted!

works great now.

----------

