UFW allow outbound from ip address, deny from others

ufw

I am trying to allow outbound connections from a specific IP address and deny outbound from all other ip addreses on port 80, but can't seem to crack it:

These are the commands:

ufw deny out 80
ufw allow out from xxx.xx.xx.xx

However it is not allowing outbound connections to port 80 from xx.xx.xx.xx:

80                         DENY OUT    Anywhere (out)
Anywhere                   ALLOW OUT   xxx.xx.xx.xx (out)

What am I doing wrong ?

Best Answer

The following would prevent outgoing traffic on port 80 but to the ip xxx.xx.xx.xx

  1. change the default outgoing open in ufw

    ufw deny out 80
    
  2. allow outgoing to the specific ip:

    ufw allow out to xxx.xx.xx.xx port 80