0

I connected to my remote Linux server to adjust my network settings, but I accidentally changed some rules using iptables instead of my preferred method, ufw.

I added the rules in ufw and then ran iptables -F to flush the rules from iptables. However, I forgot that this would block my SSH connections.

I would like to connect to my server again via SSH, but even though the port I am using for SSH is allowed on ufw, my flush of iptables is blocking me from connecting.

If I ask the server maintainer to manually reboot the server (i.e., disconnect and reconnect the power cord), will ufw reconfigure iptables to allow SSH connections (as configured in the ufw rules), or do I need to log into the server via a local TTY and reenter the rules into ufw to solve the problem?

1 Answer 1

1

ufw doesn't need to flush iptables rules on reboot. That happens automatically...or, more precisely, there are no iptables rules on a freshly booted Linux system until something sets them.

ufw does exactly that. It will set the iptables rules to exactly what its configuration files tell it to set them as. That's why programs like ufw exist - iptables rules are not persistent across reboots, so programs like ufw exist to provide persistence for firewall rules.

3
  • 1
    BTW, I'd recommend telling your server maintainer to plug in a keyboard and press Ctrl-Alt-Del rather than just power-cycle the server. The chance of filesystem corruption is fairly low, but far from non-existent.
    – cas
    Commented Nov 13, 2021 at 12:53
  • The server does not have a screen attached to it, so I don't think that the keyboard idea will work. On another note, doesn't Ctrl+Alt+Del only work on Windows machines? Finally, if I'm willing to take the chance of filesystem corruption (which is lower than normal in my case because the server doesn't have a lot of read/write activity going on), all I would need to do to reset the iptables to the UFW rules is unplug the server and plug it back in? Commented Nov 13, 2021 at 14:24
  • yes, just reboot it. that's what i said in my answer. btw: 1. screens and keyboards are independent of each other, you don't need a screen for a keyboard to work. 2. linux can trap keypress combinations and sequences, and most linux machines are configured to run shutdown -r now or similar on Ctrl-Alt-Del. 3. it's your server, you can reboot it however you want...but if you want to avoid the risk of fs corruption, then make it do a clean shutdown. I was just pointing out that the risk is low but not zero. I often take that risk, but only after trying a clean shutdown fails.
    – cas
    Commented Nov 14, 2021 at 6:12

You must log in to answer this question.

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