In Ubuntu There is no any service to start iptables like Redhat, Centos & Fedora. We can add iptables in startup using below instructions.
- First open the required ports. See iptables.
# sudo /sbin/iptables -A INPUT -p tcp --dport ssh -j ACCEPT
Let's Check your Iptables Rule..
# sudo /sbin/iptables
Saving iptables
- If you were to reboot your machine right now, your iptables configuration would disappear. Rather than type this each time you reboot, however, you can save the configuration, and have it start up automatically. To save the configuration, you can use iptables-save and iptables-restore.
- Save your firewall rules to a file
#sudo sh -c "/etc/iptables-save > /etc/iptables.rules"
Configuration on startup using /etc/network/interfaces
- Modify the /etc/network/interfaces configuration file to apply the rules automatically. You will need to know the interface that you are using in order to apply the rules - if you do not know, you are probably using the interface eth0, although you should check with the following command first to see if there are any wireless cards:
#iwconfig
Edit /etc/network/interfaces with your favourite editor.
When in the file, search for the interface you found, and at the end of the network related lines for that interface, add the line:pre-up iptables-restore < /etc/iptables.rules
- You can also prepare a set of down rules, save them into second file /etc/iptables.downrules and apply it automatically using the above steps:
post-down iptables-restore < /etc/iptables.downrules
No comments:
Post a Comment