5

I get my own ip address (maybe 123.45.6.7).

iptables -I INPUT -s 123.45.6.7 -j DROP

Now i was blocked myself,when i login server with other pc ,how to write iptables command to unblock myself?

I don't want to run the iptables -F .

showkey
  • 149
  • Possibly a duplicate of http://askubuntu.com/questions/193858/how-to-delete-or-unblock-an-ip-address-listed-in-iptables-firewall – BDRSuite Oct 27 '14 at 15:07

2 Answers2

9

If only a single rule matches the source address and action you can delete the rule by simply replacing -I (insert) by -D (delete):

iptables -D INPUT -s 123.45.6.7 -j DROP

If there are multiple rules matching you can list all the rules:

iptables -L INPUT -n --line-numbers

and delete the rule by its number n:

iptables -D INPUT n
2

allow access to an IP

iptables -A INPUT -s xx.xx.xx.xx -j ACCEPT

to allow access to an IP to a specific port using iptables

iptables -A INPUT -p tcp -s xx.xx.xx.xx --dport PORT -j ACCEPT
BDRSuite
  • 6,234