iptables insert and add IP

Result of DROP is Connection Refused

Iptables is a firewall, installed by default on all official Ubuntu distributions (Ubuntu, Kubuntu, Xubuntu). When you install Ubuntu, iptables is there, but it allows all traffic by default. Ubuntu comes with ufw – a program for managing the iptables firewall easily.

  • Reject Specific IP in iptables
    • sudo iptables -I INPUT -s 111.111.111.111 -j DROP
  • Show IP List in iptables
    • iptables -L INPUT --line-numbers
Chain INPUT (policy ACCEPT)
num             target        prot        opt          source          destination
1               DROP          all         --           111.111.111.111 anywhere
  • Delete IP on IP List in iptables
    • iptables -D INPUT 1
  • Flushing the List in iptables
    • sudo iptables -F -t nat -v
Flushing chain PREROUTING'
Flushing chain INPUT'
Flushing chain OUTPUT'
Flushing chain POSTROUTING'