Linux – UFW: Translating iptables rule to UFW

firewalliptableslinuxUbuntuufw

This is the iptables rule:

-A INPUT -i eth0 -s 10.2.0.51,10.2.0.52 -d 228.0.0.3 -j ACCEPT

How can I translate it to ufw rule?

I´ve tried:

root@localhost:~# sudo ufw allow from 10.2.0.51,10.2.0.,52 to 228.0.0.3 to any port
ERROR: Wrong number of arguments

root@localhost:~# sudo ufw allow from 10.2.0.51,10.2.0,52 to 228.0.0.3 to any port proto tcp
ERROR: Wrong number of arguments

What am I missing?

Best Answer

The syntax is following:

sudo ufw allow from <target> to <destination> port <port number> proto <protocol name>

so, you should run

sudo ufw allow from 10.2.0.51,10.2.0.52 to 228.0.0.3

it will allow all ports and all protocols. For TCP only:

sudo ufw allow from 10.2.0.51,10.2.0.52 to 228.0.0.3 proto tcp
Related Topic