Fixing Network & Firewall Lockouts

One of the most common reasons for losing access to a server is a misconfigured network setting or a firewall rule that accidentally blocks your own IP. The Linux rescue system lets you bypass this, access your configuration files directly, and fix the problem.

Prerequisite: This guide must be performed from within the Linux rescue system. If you have not started rescue mode yet, see the guide on starting rescue mode first.

Step 1: Mount Your Server's Filesystem

After booting into rescue mode and connecting via SSH, you must mount your server's main partition to make its files accessible. First, identify your main partition:

Terminal
lsblk

Look for your main partition — typically /dev/sda3, or /dev/md2 for a software RAID setup. Then mount it:

Terminal
mount /dev/sda3 /mnt

Replace /dev/sda3 with your actual partition name. Your server's entire filesystem is now accessible under /mnt.

Step 2: Locate and Edit the Problematic File

Navigate to the relevant configuration file and edit it. The location depends on what needs to be fixed and which Linux distribution you are running.

Fix a firewall lockout (iptables)

If you were locked out by an iptables rule, edit the rules file directly. The location varies by distribution:

Debian / Ubuntu — /etc/iptables/rules.v4
Terminal
nano /mnt/etc/iptables/rules.v4
CentOS / AlmaLinux — /etc/sysconfig/iptables
Terminal
nano /mnt/etc/sysconfig/iptables

Find the rule that is blocking your access — it will be a DROP or REJECT rule. Either delete the line entirely or comment it out by adding a # at the beginning.

Fix a network configuration error

If you made an error in a network interface configuration file — such as a wrong IP address, netmask, or gateway — edit the corresponding file:

Debian / Ubuntu — /etc/network/interfaces
Terminal
nano /mnt/etc/network/interfaces
CentOS / AlmaLinux — /etc/sysconfig/network-scripts/ifcfg-eth0
Terminal
nano /mnt/etc/sysconfig/network-scripts/ifcfg-eth0

Correct any mistakes, save the file, and proceed to the next step.

Step 3: Save and Reboot Safely

Once you have corrected and saved the configuration file, the fix is complete. Do not reboot from within the rescue environment.

1.Type exit to close the SSH session
2.Go to the PowerPanel and cancel rescue mode — this will trigger a safe reboot into your production OS

Always cancel rescue mode via the PowerPanel — never reboot directly from within the rescue environment or VNC session.

Further Recovery Guides

Back to the Linux rescue overview for more guides on what you can do in rescue mode.