To configure a Linux firewall to allow connections to a Samba server, you will need to open the necessary ports in the firewall. Samba uses the following ports:
To open these ports in the iptables
firewall, you can use the following commands:
iptables -A INPUT -p udp --dport 137 -j ACCEPT iptables -A INPUT -p udp --dport 138 -j ACCEPT iptables -A INPUT -p tcp --dport 139 -j ACCEPT iptables -A INPUT -p tcp --dport 445 -j ACCEPT
These commands will allow incoming connections to the specified ports. Be sure to allow only the ports that you need to expose to the network.
It is also a good idea to limit access to the Samba ports to specific IP addresses or subnets if possible. This can be done by specifying the source IP address or subnet in the iptables
rule, like this:
iptables -A INPUT -p udp --dport 137 -s 10.0.0.0/24 -j ACCEPT
This will allow incoming connections to port 137 only from IP addresses in the 10.0.0.0/24
subnet.
Remember to save your firewall rules after making any changes, so that they will be applied on boot. You can do this using the iptables-save
command.