The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Saved iptables rules not found

Discussion in 'Security' started by Musthafa, Jan 2, 2017.

Tags:
  1. Musthafa

    Musthafa Member

    Joined:
    Dec 14, 2016
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Dubai
    cPanel Access Level:
    Root Administrator
    Hi,

    I am trying to block a particular IP accessing my server via iptables as "iptables -I INPUT -s x.x.x.x -j DROP"
    Then saved iptables by "service iptables save" and restarted "service iptables restart"
    When I checked the saved rules after some time by this command "iptables -L -n | grep 'x.x.x.x' ", I couldn't find it in the saved list. Why?

    Note::I dont have a csf installed in whm

    Any help are appreciated.
     
  2. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,405
    Likes Received:
    53
    Trophy Points:
    28
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hi,

    Try below commands:
    # cp -ar /etc/sysconfig/iptables /etc/sysconfig/iptables_BK
    # iptables -A INPUT -p tcp -s x.x.x.x -j DROP
    # iptables-save >> /etc/sysconfig/iptables

    Note: Don't forget to back up correct IPtables file based on its appropriate location on your server..
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,204
    Likes Received:
    1,297
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You may also want to consider installing a plugin such as CSF for easier management of your IPtables firewall rules.

    Thank you.
     
  4. Musthafa

    Musthafa Member

    Joined:
    Dec 14, 2016
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Dubai
    cPanel Access Level:
    Root Administrator
    Hi,

    Sorry for the late reply. I found out that the rules are being saved in /etc/sysconfig/iptables, but is not showing when I check with iptables -L -n command.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,204
    Likes Received:
    1,297
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You may want to consider installing a third-party firewall management utility such as CSF if you are having trouble manually saving your system's iptables firewall rules:

    ConfigServer Security & Firewall (csf)

    Thank you.
     
  6. Musthafa

    Musthafa Member

    Joined:
    Dec 14, 2016
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Dubai
    cPanel Access Level:
    Root Administrator
    Thank you for your reply!:)
     
  7. NixTree

    NixTree Well-Known Member

    Joined:
    Aug 19, 2010
    Messages:
    404
    Likes Received:
    2
    Trophy Points:
    143
    Location:
    Gods Own Country
    cPanel Access Level:
    Root Administrator
    Twitter:
    were the rules showing fine after running the command "service iptables save" ?
     
  8. Musthafa

    Musthafa Member

    Joined:
    Dec 14, 2016
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Dubai
    cPanel Access Level:
    Root Administrator
    Yes,
    it shows when checking with the command iptables -L -n. After some time it goes nowhere, but still shows in the /etc/sysconfig/iptables directory.
     
  9. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,204
    Likes Received:
    1,297
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Could you verify if installing CSF addresses the issue?

    Thank you.
     
  10. Musthafa

    Musthafa Member

    Joined:
    Dec 14, 2016
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Dubai
    cPanel Access Level:
    Root Administrator
    Sorry,
    I can not install it right now. I am using Centos 5.11 which I think don't support csf, and right now I am not able to upgrade the OS.

    Thank you
     
  11. Musthafa

    Musthafa Member

    Joined:
    Dec 14, 2016
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Dubai
    cPanel Access Level:
    Root Administrator
    There is an update, some rules are missing from iptables. I blocked a bad bot before two weeks with its IP subnet, now its again accessing my website and creating load.

    /etc/init.d/iptables save - thats all I need to do after applying the rule right?
     
  12. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,204
    Likes Received:
    1,297
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Yes, that command will save your iptables rules on CentOS 5.

    Thank you.
     
Loading...

Share This Page