Linux Administration Cookbook
上QQ阅读APP看书,第一时间看更新

ufw

In your Ubuntu VM, ufw probably won't be enabled by default. We will enable it, but first we're going to add a rule to make sure that we can get back in once the firewall is up:

vagrant@ubuntu1:~$ sudo ufw allow ssh/tcp
Rule added
Rule added (v6)

You can enable it with the following command:

vagrant@ubuntu1:~$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup

We can now see the status of our firewall by using the status verbose option:

vagrant@ubuntu1:~$ sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip

To Action From
-- ------ ----
22/tcp ALLOW IN Anywhere
22/tcp (v6) ALLOW IN Anywhere (v6)

The firewall is active, and there's a 22/tcp allow rule to allow us in.