Diciembre 23

Insert an iptables rule on a specific line number with a comment, and restore all rules after reboot

# First get the iptables list with the line numbers enabled
$ iptables -nL --line-numbers

# Look up the line number you want to use (the exisitng rule will shift down) and insert your rule
$ iptables -I INPUT {LINE_NUMBER} -i eth1 -p tcp --dport 21 -s -j ACCEPT -m comment --comment "This rule is here for this reason"

# Aftarwards i always save my rules to a file in etc so i can reload them at the next reboot
$ iptables-save > /etc/iptables.local

# (To do this, add the following rule to your /etc/rc.local file)
/sbin/iptables-restore < /etc/iptables.local

Copyright 2018. All rights reserved.

Posted Diciembre 23, 2016 by admin in category "TIPS AND TRICKS