Sunday, April 29, 2012

Samba: Linux Iptables Firewall Configuration

How do I configure iptables firewall under CentOS / Fedora / RHEL / Redhat Linux to allow access to the Samba server? How do I open TCP ports # 137, 138, 139 and 445 under Linux so that all Microsoft Windows machine can access files and printer on a Linux host?

The Samba server can be configured to allow access to certain hosts. However, iptables prevent the access over the Internet. You must allow only the systems on your network as clients of the Samba Linux server.

Iptables Open Port 137, 138, 139 and 445

Edit /etc/sysconfig/iptables file, enter:
# vi /etc/sysconfig/iptables
To allow access to 192.168.1.0/24 network only add the following before the final LOG & DROP statements:
-A RH-Firewall-1-INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 137 -j ACCEPT
-A RH-Firewall-1-INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 138 -j ACCEPT
-A RH-Firewall-1-INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 139 -j ACCEPT
-A RH-Firewall-1-INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 445 -j ACCEPT
 
Save and close the file.

Restart Firewall

Type the following command:
service iptables restart

No comments:

Post a Comment