I'm trying to figure out UFW on ubuntu and it's a little confusing.
My server setup has multiple adapters, one of the is external to the web and the others are internal.
Say the external is en0 and internal is en1, i want to block all incoming ports except 443 on the en0 adapter only, the en1 should be left to allow every port in and out.
Another case on another server i want to block every incoming port on en0 except 80,443 and 22
CodePudding user response:
You need to deny all
first -- Then allow just 443 .. And make sure your specific adapter is mentioned in the rule .. So FIRST deny all on en0. Then allow https
. Then allow all on en1 ... Like so:
ufw default deny incoming on en0
ufw allow https on en0
ufw allow 10000 on en0
ufw allow 8080 on en0
ufw default allow in on en1
ufw deny 3939 on en1
UPDATE you can also choose physical port numbers instead of protocols as well. See above. The above set of rules would allow ONLY 443, 10000, and 8080 on en0
. And would allow all except 3939 for en1
The rules cascade .. So the (last entered) overrides the rule (previously entered) .. That's what makes this firewall so simple.