I recently had a server hosted on OVH, which I can access via SSH. On this server is installed a data collection tool (Cyber), on Linux and accessible from a Web interface.
This tool must be accessible only by my network in SSH and for the Web interface.
So I created the following tables:
38531 5164K ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
195K 6576K ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
9 432 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpts:6100:6200
5 260 ACCEPT tcp -- * * xxx.xxx.xx.xx 0.0.0.0/0 tcp dpt:80
336 17472 ACCEPT tcp -- * * xxx.xxx.xx.xx 0.0.0.0/0 tcp dpt:443
10 580 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:xxxx (ssh)
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
2703K 188M ACCEPT all -- * lo 0.0.0.0/0 0.0.0.0/0
215K 15M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
21 12096 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpts:6100:6200
0 0 ACCEPT tcp -- * * 0.0.0.0/0 xxx.xxx.xx.xx tcp dpt:443
0 0 ACCEPT tcp -- * * 0.0.0.0/0 xxx.xxx.xx.xx tcp dpt:80
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp spt:xxxx (ssh)
In "policy" ACCEPT, I added the different rules:
enable local loop
maintain established connections
allow ping
allow access to ports 6100 and 6200 because I believe OVH uses them for monitoring
allow https and http access for my network address (freebox)
allow SSH access through a new port
I then passed the Policy in DROP for the three rules, INPUT, OUTPUT, FORWARD (hoping that it had to be done like that, it was to avoid me being blocked)
Then, I researched on the internet how to avoid as much as possible certain attacks such as DDOS, flood etc.
I found these commands:
# Anti ddos
iptables -A INPUT -p tcp --syn -m limit --limit 2/s --limit-burst 30 -j ACCEPT
# Anti-scan
iptables -A INPUT -p tcp --tcp-flags ALL NONE -m limit --limit 1/h -j ACCEPT
iptables -A INPUT -p tcp --tcp-flags ALL ALL -m limit --limit 1/h -j ACCEPT
# As for ICMP:
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
First, do you think the created table is well done? Is there a problem with the order of the rules, a lack of optimization or security?
Then would the above rules work? I fully understand what they are for, but I'm still having trouble spotting all possible vulnerabilities and if it's annoying for the servers where a lot of http requests are made.
Also, I did not put anything in FORWARD, for me, there is no use for it but I may be wrong