Fixing Network & Firewall Lockouts
A wrong network setting or a firewall rule that blocks your own IP is a common reason for losing access to a Linux server. This guide shows how to correct the configuration files from the Linux rescue system.
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:
Look for your main partition — typically /dev/sda3, or /dev/md2 for a software RAID setup. Then mount it:
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:
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. If your server uses ufw (Ubuntu), set ENABLED=no in /mnt/etc/ufw/ufw.conf. If it uses firewalld (AlmaLinux / Rocky Linux), switch into your system via chroot and run systemctl disable firewalld.
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:
Replace eth0 with the name of your connection file; older installations may still use /etc/sysconfig/network-scripts/ifcfg-eth0. On Ubuntu, the network is configured with Netplan in the .yaml files under /mnt/etc/netplan/. 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.
exit to close the SSH sessionAlways 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.