I would like to configure my VPS in the way that it ONLY accepts connections from outside on port 22 (where sshd listens) and ICMP requests. Everything else from outside should be rejected. Inside the server, everything should be allowed. Do the following rules create the desired behaviour?
iptables -A INPUT --jump ACCEPT --protocol all --source 127.0.0.1
iptables -A INPUT --jump ACCEPT --protocol tcp --dport 22
iptabels -A INPUT --jump ACCEPT --protocol icmp
iptables -A INPUT --jump ACCEPT --match state --state ESTABLISHED,RELATED
iptables -A INPUT --jump REJECT --protocol all
I am not completely sure if ACCEPT rules will "win" over the last overall REJECT
--source 127.0.0.1
to determine if a packet is safe to accept. See http://serverfault.com/a/825231/4131 – Bruno Bronosky Jan 10 '17 at 05:53