Search code examples
bashiptables

Select yes in the terminal via Bash when using iptables-save


When I run this:

sudo iptables-save > /etc/iptables/rules.v4

I get a popup inside of the terminal. It asks:

Save current IPv4 rules?││││<Yes><No>

How do I force yes? In other words is there a -y for iptables-save?

Or is there something I can add to my bash script to select yes?


Solution

  • I tried this solution: https://askubuntu.com/questions/339790/how-can-i-prevent-apt-get-aptitude-from-showing-dialogs-during-installation/340846 and it seems to work.

    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