Ubuntu UFW 3x specific IP addresses only to access a specific port
First lets deny all access:
sudo ufw default deny incoming
sudo ufw default allow outgoing
Now limit out inbound traffic to ip
via these ports
:
sudo ufw allow from 1111.1111.1111.1111 to any port 33
sudo ufw allow from 2222.2222.2222.2222 to any port 33
sudo ufw allow from 3333.3333.3333.3333 to any port 33
If adding a specific protocol to the rules above:
sudo ufw allow from 1111.1111.1111.1111 proto udp to any port 33
Now check your rules:
sudo ufw status
To delete these rules at any time:
sudo ufw delete allow from 1111.1111.1111.1111 to any port 33
Source:
https://help.ubuntu.com/community/UFW
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-14-04