Block the entire range of IP address in Linux using hosts.deny
I want to block some IP addresses on my Linux server from remote access. Is this possible? I want to block the entire range of 58.50.0.0. I think I need to put this information on hosts.deny file but how can I do that? Can you help me? Is there any simpler way to achieve this?
Re: Block the entire range of IP address in Linux using hosts.deny
I am not sure if sshd would respond to /etc/hosts.deny. However you can try installing apf firewall use "apf -d IP_address" to block IP address range.
Re: Block the entire range of IP address in Linux using hosts.deny
hosts.deny file describes the names of the hosts which are not allowed to use the local INET services, as decided by the '/usr/sbin/tcpd' server. So add the IP address into hosts.deny file using:
For example:
Re: Block the entire range of IP address in Linux using hosts.deny
You can even try droping all packets from that network in your firewall using something like:
Code:
# iptables -I INPUT -j DROP -s 58.50.0.0/16
However if you are using "ALL" statement just remember that you must use a comma separator after each /etc/hosts.deny entry:
Code:
ALL: ip_address1, ip_address2, ip_address3, ....