Bad Iptables Argument
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...
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 DROP
But 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 DROP
Exclamation mark needs to be prefixed, when you are trying to make oposite match.