Like many Linux users, I use Guarddog as a frontend to my iptables firewall. At some point, I noticed that Guarddog started acting strangely. Every time I restarted my computer, all internet traffic was blocked (both incoming and outgoing). The only way to fix this situation was to open Guarddog and press “Apply” (without making any changes). While it was annoying, it didn’t bother me much because I used to restart my computer about once a month. But a few days ago, I decided to solve this problem once and for all.
I noticed that Guarddog doesn’t tell iptables to save the settings permanently. Instead, it creates a script under /etc/rc.firewall in which it saves the firewall settings. When applying firewall settings in Guarddog, it just runs this script (after possibly modifying it). The solution is to run this script automatically upon startup, after starting iptables.
In Gentoo (and some other distributions), this can be done using the initscripts. Put the following code inside /etc/init.d/guarddog (if you are using a different distribution, your path might be different):
# This is an initscript that applies Guarddog's rules on startup
depend() {
after iptables
}
start() {
ebegin "Applying firewall rules - Guarddog"
/etc/rc.firewall
eend $? "Firewall rules not set"
}
After you create the file, you will need to actually add it to the list of initscripts that run at startup. This can be be done using the following command:
rc-update add guarddog default
Guarddog rules will now be applied at startup, and there will be no need to open Guarddog to apply the rules after every boot.