Samba is a popular open-source implementation of the SMB/CIFS protocol, which allows file and printer sharing between different operating systems. If you are running Samba on a Linux server, you may want to configure your iptables firewall to allow Samba traffic.
Here are the steps to configure iptables for Samba:
- Open the iptables configuration file for editing:
sudo nano /etc/sysconfig/iptables
- Add the following rules to allow Samba traffic:
-A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
These rules allow incoming traffic to Samba’s ports, which are 137, 138, 139, and 445. The state
module is used to match only new connections.
- Save and exit the file.
- Restart the iptables service to apply the new rules:
sudo service iptables restart
You should now be able to access your Samba server from other computers on the network.
Note: If you are using firewalld instead of iptables, you can use the following commands to allow Samba traffic:
sudo firewall-cmd --add-service=samba --permanent
sudo firewall-cmd --reload
These commands add the Samba service to the firewall and reload the rules.