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.

iptables rules not up after reboot

Discussion in 'Security' started by Elvico, Nov 5, 2014.

  1. Elvico

    Elvico Member

    Joined:
    Nov 5, 2014
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi All
    sorry I'm new on cpanel and on this forum.

    I tried to setup some fw rules on my cpanel.

    I wrote this in the root shell :
    Code:
    iptables -I INPUT 1 -p tcp --dport 3306 -j DROP
    iptables -I INPUT 1 -p tcp -s <myip> --dport 3306 -j ACCEPT
    iptables -L shows :
    Code:
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
    ACCEPT     tcp  --  <myip>  anywhere            tcp dpt:mysql 
    DROP       tcp  --  anywhere             anywhere            tcp dpt:mysql 
    acctboth   all  --  anywhere             anywhere 
    It's ok. I do:
    Code:
    service iptables save
    vi /etc/sysconfig/iptables shows :
    Code:
    -A INPUT -s <myip>/32 -p tcp -m tcp --dport 3306 -j ACCEPT
    -A INPUT -p tcp -m tcp --dport 3306 -j DROP
    Now if I reboot, iptables -L does not show the rules :
    Code:
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
    acctboth   all  --  anywhere             anywhere     
    If i restart iptables. service iptables restart, ptables -L shows my rules
    Code:
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
    ACCEPT     tcp  --  <myip>  anywhere            tcp dpt:mysql 
    DROP       tcp  --  anywhere             anywhere            tcp dpt:mysql 
    acctboth   all  --  anywhere             anywhere           
    My question is simple :

    How can i get my iptables rules up just after a reboot ?

    Thank you in advance for your help !
     
  2. Elvico

    Elvico Member

    Joined:
    Nov 5, 2014
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Ok i found the answer myself :)

    Code:
    chkconfig iptables on
    thx to the "similar thread" section at the bottom.

    Now I'll try to find what ports needs to stay open to keep cpannel work.
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    671
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    I am happy to see you were able to resolve the issue. Note that you may want to consider using a third-party firewall management utility such as CSF:

    ConfigServer Security & Firewall

    Thank you.
     
Loading...

Share This Page