Remove IPtables rules from rescue system

Home » Blog » Remove IPtables rules from rescue system

Remove IPtables rules from rescue system

Remove IPtables rules from rescue system

Remove IPtables rules from rescue system

Hey, this article explains how you can remove IPtables rules if they are blocking access to the server. This usually happens if you wrongly configured IPtables or got any port blocked mistakenly like SSH port. Following the below steps to get it fixed.

Operating System : These steps are tested on Centos 6, however not tested on other operating systems.

Steps:

  1. Boot your server into rescue system. (If you cannot boot it you can ask your server provider to do this for you.)
  2. Login to rescue system via SSH and then:
    1. List hard disk partitions:
        1. run:
        2. # fdisk -l
        3. Output will be like:
        4. Device    Boot     Start       End    Blocks  Id System/dev/sda1 *         2048   1026047    512000  83 Linux/dev/sda2        1026048 234436607 116705280  8e Linux LVM/dev/sda3      234436608 234440703      2048  83 LinuxDisk /dev/mapper/vg-root: 102.6 GiB, 110125645824 bytes, 215089152 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/vg-tmp: 1 GiB, 1073741824 bytes, 2097152 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes
        5. This is your root partition : Disk /dev/mapper/vg-root: 102.6 GiB
        6. Now mount this partition on /mnt point:
          # mount /dev/mapper/vg-root /mnt
        7. Nothing will be shown if above command succeeds.
        8. Now navigate to the sysconfig directory where iptables rules are saved:
          # cd /mnt/etc/sysconfig
        9. There is file called iptables which stores all the iptables rules. You just have to rename it:
          # mv iptables iptables-old
          # mv iptables.save iptables.save-old
        10. Now you have changed iptables rules and ready to reboot your system into original operating system, but you need to unmount the partition as follows:
        11. # cd

       

      1. # umount /dev/mapper/vg-root
      2. Now you’re ready to reboot your system into original operating system. Just change boot order from the dedicated panel (if provided by provider) or ask your provider to change it.
      3. Now, you should be able to access your server without any issue.
      4. # reboot

Leave a Comment

2 − 1 =