ufw weirdness on Ubuntu 20:04 droplet--I don't understand why allowing/denying tcp/22 affects all other ports
Newbie here so I apologize in advance for any ignorance.
I’m setting up my first droplet. As I configuring my firewall with ufw, I’m getting some weird behavior. I start with default deny incoming and default allow outgoing. Then when 22/tcp is allowed, ssh works on any other open port, including mosh. Whenever 22/tcp is denied, ssh no longer works on any other port (times out when I attempt to connect). Mosh also times out when I attempt to connect if 22/tcp is denied. After denying 22/tcp, if I allow, say, 4000/tcp, I still can’t ssh into any port, and even when ufw status shows that 60000:61000 is allowed, mosh won’t work. If I just allow 22, ssh and mosh still don’t work. Once I allow 22/tcp, everything works again: 4000, 60000:61000, etc.
It’s frustrating me because on the little ssh server I put together at home (also Ubuntu 20.04 using ufw), I like to close 22 and open a different port to work on. I can’t figure out how to do that on this droplet.
Can anyone explain to me what’s going on?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×