0

I am adding a particular interface as an trusted zone using below command

firewall-cmd --zone=trusted --change-interface=eth0

Now suppose I have multiple interfaces(like eth0, eth1, bond0, bond1) and I want to add all of them once, by executing the above command written in a bash script.

What will be the syntax and command for adding all the interfaces by executing above command once?

2

This will get all the device names and then proceed to run the command for every interface.

for i in $( ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d' ); do
    firewall-cmd --zone=trusted --change-interface=$i
    echo "Added $i to trusted\n"
done
  • It would be really great if you can explain the working of this 's/[ \t].*//;/^(lo\|)$/d' syntax. Thanks – Neeraj Sep 15 '17 at 20:16
  • Lot to explain.. Look at this grymoire.com/Unix/SedChart.pdf . It will explain well what the syntax means. – Hunter.S.Thompson Sep 15 '17 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.