Iptables – saving iptables rules without logging in to root

fedora-22iptablesrootrulessudo

I am trying to save iptables rules file to /etc/sysconfig/iptables. I want to do this without logging in to root. I tried to using

sudo iptables-save > /etc/sysconfig/iptables

but it throws permission denied error.

How can i save the file without logging in to root ? I am using this in my app so i don't want to login to root through the app.

Thanks

Best Answer

To use sudo, you can do sudo iptables-save | sudo tee /etc/sysconfig/iptables

The shell don't have the right to write in /etc/sysconfig/iptables, as it is run in your user.

Related Topic