Ubuntu block an ip with iptables

Sometimes as a developer or server administrator you need to block certain IP addresses from accessing your server.

In the example IP address that we will be using is going to be The syntax that we will use to block an IP address is

sudo iptables -A INPUT -s [the ip] -j DROP

The A tells iptables to add the rule. So in our example to block from our server the command would look like

sudo iptables -A INPUT -s -j DROP

See also: Linux: 20 Iptables Examples For New SysAdmins