built-in firewall. UFW simplifies the user tasks and syntax but really just uses
iptables. You probably won’t need to know this on your Ubuntu machine,
but for completeness and to help you in case you use a different Linux
distribution in the future, Table 20.2 lists simple, basic commands as a brief
introduction to iptables.
In the table, you see words in all-caps like ACCEPT and DROP, which are
policies to be set for things called chains. Chains are descriptions of specific
types of network access, such as INPUT, FORWARD, and OUTPUT in Table
20.2, as well as other interactions in a network. You can, for example, define
the default policy as DROP, which means to reject, and then ALLOW specific
types of traffic to go through the firewall. iptables is quite complex and
incredibly powerful.
Table 20.2 Useful Commands for iptables
Command Actions PerformedUsage: commandsudo iptables -LLists the currently set firewall rulessudo iptables -L
-vnLists the currently set firewall rules but with more
detailsudo iptables -FDeletes all currently set firewall rulessudo iptables -P
INPUT DROPDrops all incoming trafficsudo iptables -P
FORWARD ACCEPTAccepts all forwarded trafficsudo iptables -P
OUTPUT DROPDrops all outgoing trafficsudo iptables -A
INPUT -s 8.8.8.8
-j DROPDrops all traffic from a specific IP address (the
example here is a Google DNS server, and you
probably don’t want to block that one...)You can block or allow traffic based on IP address, NIC, port, network, and
more. You can set iptables to log all actions or just specific actions. You