Bad iptables argument

12,372

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.

Share:
12,372

Related videos on Youtube

VeLKerr
Author by

VeLKerr

Java developer and Python learner.

Updated on September 18, 2022

Comments

  • VeLKerr
    VeLKerr over 1 year

    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?