We are facing IP abuse issues and want to completely BLOCK ssh and ability to ping our servers running Oracle Linux 6.7 and only allow vnc connections. How to achieve this using linux firewall or iptables?
As OEL 6 using iptables;
Allow ICMP traffic to leave your server, ie so you can ping out
$ iptables -A OUTPUT -p icmp -o eth0 -j ACCEPT
Then block IMCP replies:
$ iptables -A INPUT -p icmp --icmp-type echo-reply -j DROP $ iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
SSH would be the same, assuming SSH is on port 22.
$ iptables -A INPUT -p tcp --dport 22 -j DROP
but you could allow SSH from a single IP, or range;
$ iptables -I INPUT -p tcp -s 18.104.22.168 --dport 22 -j ACCEPT
(Note the use of
-I to insert the rule at the start of the
ACCEPT chain instead of using
-A which would place it after the
DROP rule and negate its effect.)