/etc/init.d/iptables: line 268: restorecon: command not found




Error:

After adding a new rule in iptables, it is needed to save those rule and restart iptables.
When saving iptables rule,

# root@server [~]# service iptables save

iptables: Saving firewall rules to /etc/sysconfig/iptables: /etc/init.d/iptables: line 268: restorecon: command not found
                                                           [FAILED]

The rules will not be saved and we will keep getting the above error when saving iptables.

Solution:

The reason in getting such an error message is because of the  missisng of restorecon file.

See the result of the follwing command, 'restorecon' is missiing in there.

root@server [~]# ls -l /sbin/ | grep restore
lrwxrwxrwx  1 root root         14 Jan  9 22:23 iptables-restore -> iptables-multi*

restorecon is provided by policycoreutils package. Try re-installing policycoreutils package and see the result of the above command.

# yum update policycoreutils


After the update, run the following command to check whether 'restorecon' available or not.

root@server [~]# ls -l /sbin/ | grep restore
lrwxrwxrwx  1 root root         14 Jan  9 22:23 iptables-restore -> iptables-multi*
lrwxrwxrwx  1 root root          8 Jan 15 19:50 restorecon -> setfiles*

If you get an output as like above, it will fix the above iptables save issue.

This entry was posted by Arun Ghosh. Bookmark the permalink.