1

I'm having trouble seting-up iptables on Ubuntu 20.04.

Does anyone know why this doesn't work?

# iptables -A INPUT -m set -–match-set cf src -p tcp -m multiport –dports http,https -j ACCEPT
iptables v1.8.4 (legacy): unknown option "set"
Try `iptables -h' or 'iptables --help' for more information.

My cf has the cloudflare ip's:

for x in $(curl https://www.cloudflare.com/ips-v4); do ipset add cf $x; done
2
  • Please post the output of uname -a Aug 1, 2021 at 17:50
  • @MichaelHampton Linux server.example.com 5.4.0-80-generic #90-Ubuntu SMP Fri Jul 9 22:49:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
    – Karbust
    Aug 1, 2021 at 17:54

1 Answer 1

2

Incorrect syntax:

# iptables -A INPUT -m set -–match-set cf src -p tcp -m multiport –dports http,https -j ACCEPT

Correct syntax:

# iptables -A INPUT -m set --match-set cf src -p tcp -m multiport --dports http,https -j ACCEPT

At two places, one or two (hyphen: u002d) were replaced with a (en dash: u2013). Be careful when using word processors not designed for programming when copying scripts through them: they can alter what looks like punctuation to them but is a syntax that must not be altered. Same goes when retrieving this from some web sites not handling things correctly or even some PDF documents.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .