At first you have to mount your partitions.
The editors “vi” and “nano” are available in the rescue system. You can either modify the configuration files on your hard disk or disable the start of the firewall.
On Debian/Ubuntu
The most common configuration is the use of the packet iptables-persistent.
You can edit the configuration file that you can find here:
/mnt/sda2/etc/iptables/rules.vX
The “X” has to be replaced by “4” (IPv4) or “6” (IPv6) depending on the rule that is blocking you.
On CentOS
At first you'll have to chroot yourself on your partition:
sudo chroot /mnt/sda2
Then execute the following code:
chkconfig iptables off
Note: This command is initially intended for CentOS 6, but it is also compatible with CentOS 7
Once you have finished the modification, click on “Boot in normal mode” in your account to restart your server.