How to block IP Address in Ubuntu Firewall
In the Last tutorial We learn How to Allow IP Address from Ubuntu Firewall using ufw Allow Command. In This UFW Tutorial We are going to learn how to block IP address in Ubuntu Firewall.
To block a IP Address we use ufw deny command. We can block All network traffic or we can block IP address on Certain Network Ports.
ufw deny from <Remote-IP> to <Local-IP> proto <Protocol> port <Port Number>
Examples : UFW Block IP Address
ufw deny from 192.168.1.10 to any
Block all network traffic from the IP Address 192.168.1.10.
ufw deny from 192.168.1.10 to any proto tcp port 80
This Ubuntu Firewall rule will block IP Address 192.168.1.10 on TCP port 80
ufw deny from 192.168.1.50 to any proto udp port 53
Block UDP port 53 from IP Address 192.168.1.50
Ubuntu Firewall matched rules by the order, if one ruled matched others will not be evaluated. You can list your firewall rules by order number using ufw status numbered command.
ufw status numbered
Summary : What we Learned?
In This Tutorial we learned how to block IP address in Ubuntu firewall using ufw deny command.