1

I'm trying to set up an UFW firewall on Ubuntu like this:

  • Allow all incoming and outgoing connections to IP 1.1.1.1 (all ports);
  • Deny all other connections (incoming and outgoing);

For the first item, the command below seems to work just fine: sudo ufw allow from 1.1.1.1

The status of UFW after that shows:

To                         Action      From
--                         ------      ----
Anywhere                   ALLOW IN    1.1.1.1 

-

Now, for the second item. Is it possible just to say "deny everything else" with UFW?

The UFW Default is: deny (incoming), allow (outgoing)

If i use sudo ufw default deny outgoing , and them sudo ufw allow from/to 1.1.1.1, will the "allow" command overrule the "deny" command? That way it would work just how i need.

2 Answers 2

1

Late to the party, but I hope this will do the trick.

ufw disable
ufw reset
ufw default deny incoming
ufw default deny outgoing
ufw allow to 1.1.1.1
ufw allow from 1.1.1.1
ufw allow out from 1.1.1.1
ufw allow out to 1.1.1.1
ufw enable
0

I think iptables would be a better solution.

iptables -I INPUT -j DROP ### drop input
iptables -I INPUT -s (whitelisted address) -j ACCEPT ### allow input from whitelisted IP
iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT ### allow responses to outgoing requests

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .