w3resource

Firewall

Firewall

Firewalls play an important role to control Network Traffic.

The Linux kernel includes the Netfilter subsystem which is used to control network incoming and outgoing traffic.

Linux firewalls utilize Netfilter. The administrator tells Netfilter how to treat data packets by configuring rules in iptables, a configuration file.

In Ubuntu, we use ufw as a configuration tool for iptables.

ufw

the friendly way to create a firewall ufw: Uncomplicated firewall

installing ufw :

sudo apt-get install ufw

Enable ufw and restart the server to take effect:

You will not be able to restore the SSH connection until you configure ufw to allow SSH traffic:

sudo ufw allow 22
firewall

or

sudo ufw deny 22

ufw, examples of rules

Delete a rule:

sudo ufw delete deny 22

Allow access from a host to port 22 of any IP address on this host:

sudo ufw allow proto tcp from
192.168.0.2 to any port 22

firewall1

Allow all HTTP traffic:

sudo ufw allow http
firewall2

Use --dry-run to show the rule corresponding to a directive:

Disable the firewall:

sudo ufw disable
ufw-disable

See ststus:

sudo ufw status
ufw-status

See ditailed status:

sudo ufw status verbose
ufw-status-verbose

Application integration, predefined rules. Apply like this sudo ufw allow Postfix and sudo ufw app info Postfix to view rule details:

ufw-app-list

Previous: Email services: Postfix
Next: Software management



Follow us on Facebook and Twitter for latest update.