Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Custom script on pfsense 2.0.2

    Scheduled Pinned Locked Moved General pfSense Questions
    1 Posts 1 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      ciambellone
      last edited by

      Hello World,
      Please I want to know how to execute a custom script on pfsense.
      I've found the following procedure:
      http://forum.pfsense.org/index.php/topic,7228.0.html
      and i would to know if It is right.
      If no, how i can configure the script.
      Please, if you can check my script, It bring down one network adapter of a particular host cannot answer to a ping.

      
      #!/usr/local/etc/rc.d
      
      timeout=5         # delay between checks
      pingip='10.155.0.3'   # what to ping
      iface="em3"
      LOG_FILE="/var/log/"
      isdown=0            # indicate whether the interface is up or down
                         # start assuming interface is up
      
      while true; do
          LOG_TIME=`date +%b' '%d' '%T`
          if ping -q -c 2 "$pingip" >> /dev/null ; then      # ping is good - bring iface up
              if [ "$isdown" -ne 0 ] ; then
                  ifup $iface && isdown=0
                  printf "$LOG_TIME $0: Interface brought up: %s\n" "$iface" | tee -a $LOG_FILE
              fi
          else                                 # ping is bad - bring iface down
              beep -f 4000
              if [ "$isdown" -ne 1 ] ;  then
                  ifdown $iface && isdown=1
                  printf "$LOG_TIME $0: Interface brought down: %s\n" "$iface" | tee -a $LOG_FILE
              fi
          fi
          sleep "$timeout"
      done
      
      

      BEst regards.
      Matteo

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.