GO HERE Where is the IP updater run from and how often?

Discussion in 'Help' started by JFrost, Mar 15, 2019 at 3:50 PM.

  1. JFrost

    JFrost Member

    Joined:
    Oct 1, 2016
    Messages:
    65
    Likes Received:
    4
    On ipbx 13-13. I think it's the `ipchecker` script in the root that does the work of checking and whitelisting dynamic IPs (ie. cell phones and road-warriors).
    But where is it run from? I checked the crons and don't see it.
    And how often? I'd like to step it up so there is less delay.

    thanks.
     
  2. wardmundy

    wardmundy Nerd Uno

    Joined:
    Oct 12, 2007
    Messages:
    14,612
    Likes Received:
    2,489
  3. JFrost

    JFrost Member

    Joined:
    Oct 1, 2016
    Messages:
    65
    Likes Received:
    4
    Interesting. Still pretty novice at linux. I did a `crontab -l` as root and it came back blank. I guess that's not the same as just `cat`ing the /etc/crontab.
     
  4. JFrost

    JFrost Member

    Joined:
    Oct 1, 2016
    Messages:
    65
    Likes Received:
    4
    Yes, well. Let's ignore the snark and call it humor. That's what I searched, that's what I found. And yet still the question remained unanswered.

    So while I appreciate the thought you should really vet your lmgtfy search results next time. Those results don't answer this question - or at least nothing in the first 5 results does. Of course if you'd checked instead of off-hand snarked, you'd have caught that.

    The crontab COMMAND does not return the results of simply `cat`ing the \etc\crontab file in this case.
    Hence my follow up comment stating so.
     
  5. mainenotarynet

    mainenotarynet Not really a Guru - Just a long time user

    Joined:
    May 29, 2010
    Messages:
    584
    Likes Received:
    67
    I'm new to linux (sort of) also, know how to copy and Past commands :smile5: -- but I have read that there is crontab, and there is crontab. Huh? each user has their own crontab also (I believe you see that as crontab -e (?) the one where root uses has all the scrips that run and that's the /etc/crontab -- I usually look at that through nano /etc/crontab in this way if I want to add or edit it, it's already open for that.
     
  6. kenn10

    kenn10 Guru-ish

    Joined:
    Dec 16, 2007
    Messages:
    791
    Likes Received:
    109
    Unless it has been automated in later releases of IncrediblePBX, I believe you have to add ipchecker to the crontab yourself using update intervals of your choice. Going back a few years where whitelist inclusion began, here is Ward's initial post on Travelin' Man 3: http://nerdvittles.com/?p=815

    You can directly edit the crontab file but, for safety, I prefer to use
    Code:
    crontab - e -u root
    to add/edit entries that are not directly related to Asterisk/FreePBX.

    The default entries set up by IncrediblePBX installs are at
    Code:
    crontab -l -u asterisk
    Directly editing the /etc/crontab file may not reveal all the scheduled jobs in your system and you could end up with duplicates or conflicting entries. However, as user root, you can directly edit /etc/crontab and that may reveal whether ipchecker is already scheduled by the installer.

    Also, individual crontabs for users live in /var/spool/cron/.
     
    #6 kenn10, Mar 16, 2019 at 10:43 AM
    Last edited: Mar 16, 2019 at 11:13 AM
  7. jerrm

    jerrm Guru

    Joined:
    Sep 23, 2015
    Messages:
    434
    Likes Received:
    168
    Cron is a mess IMO. To find where (or if) a job is scheduled requires checking at least half a dozen locations.

    A (very) quick and dirty script I use to find things:
    Code:
    #!/bin/bash
    
    b="======================================================================="
    for e in `find /etc/cron.*/* /var/spool/cron/* /etc/*crontab`
      do
        [ -f $e ] && {
          echo "${b:0:${#e}}"
          echo "$e"
          echo "${b:0:${#e}}"
          cat $e | grep ".$1"
          echo -e "\n"  
        }
    done
    
    It ain't pretty, but makes finding things easier.
     
    #7 jerrm, Mar 16, 2019 at 2:18 PM
    Last edited: Mar 16, 2019 at 2:36 PM
    JFrost and ostridge like this.
  8. ostridge

    ostridge Guru

    Joined:
    Jan 22, 2015
    Messages:
    372
    Likes Received:
    66
    just checked my /etc/crontab which shows
    Code:
    */10 5-22 * * * root /root/ipchecker > /dev/null 2>&1
    
     
    wardmundy likes this.
  9. wardmundy

    wardmundy Nerd Uno

    Joined:
    Oct 12, 2007
    Messages:
    14,612
    Likes Received:
    2,489
    Correct. Decoder badge: run ipchecker every 10 minutes between 5 am and 10 pm every day.
     
  10. JFrost

    JFrost Member

    Joined:
    Oct 1, 2016
    Messages:
    65
    Likes Received:
    4
    I just ran your command against my system and ffs that's a lot of crons! Who knew. That really is a mess.

    Thanks for the script.
     
    ostridge likes this.
  11. JFrost

    JFrost Member

    Joined:
    Oct 1, 2016
    Messages:
    65
    Likes Received:
    4
    I think it's clearly been automated in IPBX. I didn't add it or I'd have known where I put it.

    And the 'add-fqdn' and 'add-ip' scripts included in IPBX wouldn't do anything without something somewhere running the ipchecker script periodically.
     
  12. JFrost

    JFrost Member

    Joined:
    Oct 1, 2016
    Messages:
    65
    Likes Received:
    4
    I'd like to run this every 1 minute. For some reason it takes a fairly long time (like 5 or 6 minutes solid) for iptables to shut down on my system.
    • Is there a problem with running it this often?
    • Anyway to speed up the iptables shutdown/restart process (I wonder if my system is exposed during this time)
    • How long does it take for iptables to shutdown on your (typical) system? (I'm on a vultr vps - 1GB ram, 25GB SSD - I don't think it's a resource issue)
    thx.
     
  13. wardmundy

    wardmundy Nerd Uno

    Joined:
    Oct 12, 2007
    Messages:
    14,612
    Likes Received:
    2,489
    If there's no change in the IP address, the ipchecker script exits immediately without doing anything else. The problem is ipchecker would be hammering the IP lookup site and your server may get blocked permanently.