I'm trying to defend Portmap using IPtables. For this I should deny receiving packages from all IPs but 192.168.0.0/24 on TCP and UDP.
For doing this I've written such IPtables rules:
iptables -A INPUT -p tcp -s! 192.168.0.0/24 --dport 111 -j DROP
iptables -A INPUT -p udp -s! 192.168.0.0/24 --dport 111 -j DROPBut I got such error:
Bad argument `192.168.0.0/24'
Try `iptables -h' or 'iptables --help' for more information.How can I edit rules to get correct ones?
1 Answer
Syntax is wrong. You have to make a rule like:
iptables -A INPUT -p tcp ! -s 192.168.0.0/24 --dport 111 -j DROPExclamation mark needs to be prefixed, when you are trying to make oposite match.