3

Will UFW create the appropriate rules in both iptables and ip6tables?

edwinksl
  • 23,569
  • 16
  • 74
  • 100

1 Answers1

7

It depends whether the rule you create is generic, such as

ufw allow 22/tcp

or is specific to one address family, such as

sudo ufw allow from 192.168.1.0/24 to any port 22 proto tcp

Ex.:

$ sudo ufw allow from 192.168.1.0/24 to any port 22 proto tcp
Rule added
$ sudo ufw status numbered
Status: active

     To                         Action      From
     --                         ------      ----
[ 1] 22/tcp                     ALLOW IN    192.168.1.0/24            

but

$ sudo ufw allow 22/tcp
Rule added
Rule added (v6)

$ sudo ufw status numbered
Status: active

     To                         Action      From
     --                         ------      ----
[ 1] 22/tcp                     ALLOW IN    Anywhere                  
[ 2] 22/tcp (v6)                ALLOW IN    Anywhere (v6)             
steeldriver
  • 131,985
  • 21
  • 239
  • 326
  • Is it safe to remove the `22/tcp (v6)` – `Anywhere` rule along with the `22/tcp` – `Anywhere` rule in order to lock down ssh access via port 22 to only one IP address? Or do I lock myself out, that way? Asking because as you show (and as it worked for me too), the command to allow only a specific IP only adds the `22/tcp` – ``, not a `22/tcp (v6)` – `` rule. – LinusGeffarth Apr 22 '22 at 18:56