This is just basic example using iptables, it needs more practice since it is complicated task.
Make sure port 80 is accessible on the server.
# telnet 80
to check iptables contents:
# less /etc/sysconfig/iptables
For blocking port 80 using command line
# iptables -I INPUT -p tcp --dport 80 -j REJECT
Save the configuration
# service iptables save
Saving firewall rules to /etc/sysconfig/iptables: [ OK ]
Restart the service
# service iptables restart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]
Loading additional iptables modules: ip_conntrack_netbios_n[ OK ]
Make sure port 80 is not accessible now.
# telnet 80
To remove the configuration enter the following command, save and restart the service:
# iptables -D INPUT -p tcp --dport 80 -j REJECT
Now, you should access port 80 again.
No comments:
Post a Comment