UFW with Python

We briefly mentioned UFW as the frontend for iptables on Ubuntu hosts. Here is a quick overview:

$ sudo apt-get install ufw$ sudo ufw status$ sudo ufw default outgoing$ sudo ufw allow 22/tcp$ sudo ufw allow www$ sudo ufw default deny incoming

We can see the status of UFW:

$ sudo ufw status verboseStatus: activeLogging: on (low)Default: deny (incoming), allow (outgoing), disabled (routed)New profiles: skipTo Action From-- ------ ----22/tcp ALLOW IN Anywhere80/tcp ALLOW IN Anywhere22/tcp (v6) ALLOW IN Anywhere (v6)80/tcp (v6) ALLOW IN Anywhere (v6)

As you can see, the advantage of UFW is a simple interface to construct otherwise complicated IP table rules. There are several Python-related tools we can use with UFW to make things ...

Get Mastering Python Networking - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.