To restore iptables rules, you can use the iptables-restore command. This command reads rules from a file and applies them to the iptables configuration. Here’s how you can do it:
-
Create a backup of your current iptables rules (optional but recommended):
iptables-save > /path/to/backup/iptables.rules -
Create a file with your desired iptables rules (e.g.,
rules.v4):*filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT -A INPUT -p tcp --dport 22 -j ACCEPT -A INPUT -j DROP COMMIT -
Restore the iptables rules from the file:
iptables-restore < /path/to/rules.v4 -
Verify that the rules have been applied:
iptables -L -v
This will restore your iptables rules as specified in the file. Make sure to adjust the file paths and rules according to your needs.
