Bash Install Iptables-Persistent Automatically

Posted on November 4, 2020 at 11:56 am

Check if iptables-persistent is installed, else install it:

if [[ $(dpkg -s iptables-persistent) != *"Status: install ok installed"* ]]; then
    echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
    echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections
    apt-get -y install iptables-persistent
fi

iptables-persistent makes sure iptables rules survive a reboot.

Receive updates via email

Other Posts

Updated Posts