3

I need to use UFW to allow only 3x different IP addresses to connect on a specific port.
Ex:
IP address [1] - 111.111.111.111
IP address [1] - 222.222.222.222
IP address [1] - 333.333.333.333
on a specific port. All other connections denied.
Any help please?
Can I simply add 3x rules one after each other for each ip address to point at the port?

5

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.