Skip to content

HOWTO: FreeBSD 9 trigger event and execute script on carp interface link change

June 1, 2012

When carp interface makes an action, the kernel sends notifies that can be used as triggers to run custom scripts.

This is howto trigger on link_up and link_down on the carp interface and start custom bash script:

1. Check included directories in /etc/devd.conf:

# grep directory /etc/devd.conf
# Each “directory” directive adds a directory to the list of
directory “/etc/devd”;
directory “/usr/local/etc/devd”;

2. vi /usr/local/etc/devd/do_notify.conf ( VERY IMPORTANT: the filename must have .conf suffix!!! )

notify 30 {
match “system” “IFNET”;
match “subsystem” “carp0”;
match “type” “LINK_UP”;
action “/root/scripts/ up”;
notify 30 {
match “system” “IFNET”;
match “subsystem” “carp0”;
match “type” “LINK_DOWN”;
action “/root/scripts/ down”;

3. vi /root/scripts/


echo `date` $state >> /var/log/carp_state.log

4. /etc/rc.d/devd restart

that’s all!


From → FreeBSD, Networking

One Comment
  1. Amazing blog! Do you have any tips for aspiring writers?

    I’m hoping to start my own website soon but I’m a little lost
    on everything. Would you advise starting with a free
    platform like WordPress or go for a paid option? There are so many options out there that I’m totally overwhelmed .. Any suggestions? Thank you!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: