Rescue Mode

How can we help?

Guides and technical documentation for your Server4You dedicated server or VPS.

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:

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
AlmaLinux / Rocky Linux — /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. 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:

Debian — /etc/network/interfaces
Terminal
nano /mnt/etc/network/interfaces
AlmaLinux / Rocky Linux — /etc/NetworkManager/system-connections/
Terminal
ls /mnt/etc/NetworkManager/system-connections/ nano /mnt/etc/NetworkManager/system-connections/eth0.nmconnection

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.

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

Further Recovery Guides

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