Iptables rule for Samba server in Red Hat Linux

You ca use these firewall rules for simple share level Samba server. But in case you are looking for iptables rule for Samba4 Active Directory follow the below link

IPtables rule for Samba4

These are the Iptables setting for Samba server to work for the source users having IP range 10.10.10.0/24 based on RedHat or CentOS Operating Systems.

Add these rules in your linux machine

# iptables -A INPUT -s 10.10.10.0/24 -p udp --dport 137 -j ACCEPT  
# iptables -A INPUT -s 10.10.10.0/24 -p udp --dport 138 -j ACCEPT  
# iptables -A INPUT -s 10.10.10.0/24 -p tcp --dport 139 -j ACCEPT   
# iptables -A INPUT -s 10.10.10.0/24 -p tcp --dport 445 -j ACCEPT  

Verify your rules

# iptables --list

to check if the firewall rules are working

# netstat -ntlp | grep smb  
tcp 0 0 :::139 :::\* LISTEN 1221/smbd   
tcp 0 0 :::445 :::\* LISTEN 1221/smbd 

How to configure Samba 3 as Primary Domain Controller in Red Hat Linux
Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
How to configure Samba 4 Secondary Domain Controller
How to secure Apache web server in Linux using password (.htaccess)
How to register Red Hat Linux with RHN (Red Hat Network )
Red hat Enterprise Linux 5.5 Installation Guide (Screenshots)
15 tips to enhance security of your Linux machine
What is the difference between "su" and "su -" in Linux?
What is swappiness and how do we change its value?
How to log iptables messages in different log file
How to auto start service after reboot in Linux
What is virtual memory, paging and swap space?