Score:0

UFW allow rule with destination and port

nc flag

Setting up UFW firewall on Ubuntu I wish to allow connections on port 22 from my local network only. I use next command:

ufw allow from 192.168.1.0/24 to any port 22

For me is unclear in the part "to any". Those explanations that I've found are very confusing. On the one hand I see explanations about destination IP address (but I'm already configuring machine with concrete IP, and it is implied that packets know my IP address, if the they have already reached my system), on the other hand I see explanation that this is IP address of source. But source IP is already specified earlier in part "from 192.168.1.0/24".

Can anybody tell me what does it finally mean, what values for "to" options we can use, and how it will impact on incoming and outgoing traffic on my Ubuntu system? What if I'll specify my own IP address (e.g. 192.168.1.25)? What if I'll specify IP address of any other system for "to" parameter?

David avatar
cn flag
A link for you to study. https://help.ubuntu.com/community/UFW
Sančiezz avatar
nc flag
@David I saw this page. There no details about <destination> parameter, and what does it mean.
FedKad avatar
cn flag
I would do `ufw allow proto tcp from 192.168.1.0/24 to any port 22`. I think `to any` has any real meaning when your Ubuntu system acts as a router.
Sančiezz avatar
nc flag
@FedKad I had the same assumption that it was meant for routing or proxying, but I didn't see any comments about this situation anywhere. As a result, there is some ambiguity, which is why I have doubts and am asking this question here.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.