0
votes

This question has been asked several times but none of the answers works for me. This is very simple, I want to block some IP access to a server

I tried this:

.htaccess

Order Deny,Allow 
Deny from 151.101.52.84

iptables -L

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
DROP       all  --  151.101.52.0/24      anywhere
REJECT     tcp  --  151.101.52.84        anywhere             tcp reject-with icmp-port-unreachable
DROP       all  --  151.101.52.84        anywhere
DROP       all  --  151.101.52.84        anywhere
DROP       tcp  --  151.101.52.84        anywhere
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http limit: avg 100/min burst 200

/etc/hosts.deny

ALL : 151.101.52.84

netstat -te | grep 151.101

tcp        0      1 ip-*-*-*-*.us-we:51181 151.101.52.84:http          SYN_SENT    apache     800352623

Already restarted httpd

Even I blocked the IP via Amazon EC2 VPC

Need to restart entire server? Need something else with iptables?

1
What is your Apache version?Quasimodo's clone
Apache is 2.4.23SuNcO
This netstat output looks like you connected from EC2 to 151.101.52.84Dusan Bajic
A2.4 does not support allow/deny any more. Use something like <RequireAll> / Require all granted / Require not ip 1.2.3.4 / </RequireAll> instead. See also httpd.apache.org/docs/2.4/howto/access.htmlQuasimodo's clone
To be clear: the connection in netstat is a connection that you initiated -- an outbound connection from you, @SuNcO, not an incoming connection. Why do you think the iptables rules are not working?Michael - sqlbot

1 Answers

0
votes

Have you tried Fail2Ban?

sudo apt-get install fail2ban