Q. How do I start Iptables firewall under RHEL / Red Hat / CentOS / Fedora Linux from a shell prompt? How do I stop firewall?
A. First, you need to configure firewall rules by editing text file located at /etc/sysconfig/iptables. You can also use setup command to configure firewall. Just type the following as root user:
# setup
Select Firewall configuration and just follow on screen instructions.
Once configuration is updated type the following command at a shell prompt:
To start firewall from a shell enter:
# chkconfig iptables on
# service iptables start
To stop firewall, enter:
# service iptables stop
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