install and configure ufw on ubuntu 12.04

ufw (uncomplicated firewall) makes it easy to allow or deny specific ports or services.

install ufw if it is not already installed.

sudo apt-get -y install ufw

enable ufw to run at boot time. since no rules are added, this will not affect your current ssh session.

sudo ufw enable

allow traffic for http, https and ssh. you can specify service names, but for this example, we specify port numbers.

sudo ufw allow 22
sudo ufw allow 80
sudo ufw allow 443

restart ufw to apply the changes immediately.

sudo service ufw restart

verify that the rules were properly applied:

sudo ufw status verbose

the projected output should look like the following:

Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing)
New profiles: skip

To                         Action      From
--                         ------      ----
22                         ALLOW IN    Anywhere
80                         ALLOW IN    Anywhere
443                        ALLOW IN    Anywhere
22                         ALLOW IN    Anywhere (v6)
80                         ALLOW IN    Anywhere (v6)
443                        ALLOW IN    Anywhere (v6)

done. firewall installed and enabled at boot time, filtering all traffic except http, https and ssh. please note that this does not filter outbound traffic in any way, it merely firewalls off all ports except those specified above.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s