All-Things-Docker-and-Kubernetes

Restrict Network Access

Network-wide Security

We can apply network-wide security using external appliances like Cisco, Fortinet, etc.

Server-level Security

As an alternative to network-wide security, we can also apply server-level security using the following:

Uncomplicated Firewall - UFW

UFW, or Uncomplicated Firewall, is a user-friendly command-line interface for managing iptables, the default firewall management tool for Linux systems.

Basic UFW Commands:

Usage Examples:

  1. Allow SSH and deny everything else:
    sudo ufw default deny incoming
    sudo ufw allow ssh
    
  2. Allow HTTP and HTTPS traffic:
    sudo ufw allow 80/tcp
    sudo ufw allow 443/tcp
    
  3. Enable UFW logging:
    sudo ufw logging on
    

Installing UFW

Installing and configuring UFW (Uncomplicated Firewall) is a straightforward process.

Sample UFW Rules

Default rules:

sudo ufw default allow outgoing
sudo ufw default deny incoming

Allow inbound connections to port 22 from a specific source IP 10.1.2.3.

ufw allow fromn 10.1.2.3 to any port 22 proto tcp  

Allow inbound connections to port 80 from a specific source CIDR 10.1.2.3/24.

ufw allow fromn 10.1.2.3/24 to any port 80 proto tcp  

Deny port 8080.

ufw deny 8080 

Deleting UFW Rules

We can use the delete command to remove a rule, or we can also specify the rule number.


Back to first page