![]() ![]() A INPUT -s xx.xx.xx.xx/32 -p tcp -m tcp -dport 110 -j ACCEPT A INPUT -s xx.xx.xx.xx/32 -p tcp -m tcp -dport 80 -j ACCEPT A INPUT -s xx.xx.xx.xx/32 -p tcp -m tcp -dport 25 -j ACCEPT A INPUT -s xx.xx.xx.xx/32 -p tcp -m tcp -dport 22 -j ACCEPT Step 3: cat savedrules.txt Example ]# iptables -L -nv -line-numberĬhain INPUT (policy ACCEPT 80 packets, 5562 bytes) You can simply save the current rules by executing the command “iptables-save” followed by the file name for save the rules. Check the current/existing rules by using the aforementioned command and save it before doing something with rules. iptables-restore (Restore back the saved rules from the file) Usage with example iptables-save (Save current/existing rules to a file)Ģ. If anything happened wrongly while editing the iptables rules we can simply restore the backup and lift the iptables as a working one.ġ. It is very useful option if you want a backup the current iptables rules prior to make any changes on it. Iptables has two commands to manage backup and restoration of current/existing rules. Num pkts bytes target prot opt in out source destination How to save current iptables rules to a text file? ![]() Num pkts bytes target prot opt in out source destinationġ 0 0 ACCEPT tcp - * * xx.xx.xx.xx 0.0.0.0/0 tcp dpt:22Ģ 0 0 ACCEPT tcp - * * xx.xx.xx.xx 0.0.0.0/0 tcp dpt:25ģ 0 0 ACCEPT tcp - * * xx.xx.xx.xx 0.0.0.0/0 tcp dpt:80Ĥ 0 0 ACCEPT tcp - * * xx.xx.xx.xx 0.0.0.0/0 tcp dpt:110ĥ 0 0 ACCEPT tcp - * * xx.xx.xx.xx 0.0.0.0/0 tcp dpt:143Ĭhain FORWARD (policy ACCEPT 0 packets, 0 bytes)Ĭhain OUTPUT (policy ACCEPT 60 packets, 10834 bytes) line-number -> List rules with rule number Example ]# iptables -L -nv -line-number Chain INPUT (policy ACCEPT 80 packets, 5562 bytes) ![]()
0 Comments
Leave a Reply. |