I currently have the following rules to allow connections to my SSH server on port 2233:
iptables -A INPUT -p tcp --dport 2233 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 2233 -m conntrack --ctstate ESTABLISHED -j ACCEPTHowever, I now need to write a rule that blocks all other incoming traffic apart from the incoming traffic to the SSH on port 2233. I also need to enable logging for all other blocked traffic to be labelled as "BLOCKED TRAFFIC >"
Any help would be greatly appreciated. Thanks!
31 Answer
Just append this:
iptables -A INPUT -j LOG --log-prefix "BLOCKED TRAFFIC > " --log-level 4
iptables -A INPUT -j DROPPackets not matched by previous ACCEPTs (or DROPs) will be processed and so get LOGged and then DROPped...