ifplugd
ifplugd
是一个以太网链路状态监控守护程序,当您插入或移除电缆时,它会执行脚本来配置以太网设备。按照以下步骤安装和配置 ifplugd
守护程序。
安装 ifplugd
即使交换机未连接到互联网,您也可以安装此软件包。该软件包位于 Cumulus Linux 镜像上的 cumulus-local-apt-archive
存储库中。
要安装 ifplugd
在安装守护程序之前更新交换机
cumulus@switch:~$ sudo -E apt-get update
安装
ifplugd
软件包cumulus@switch:~$ sudo -E apt-get install ifplugd
配置 ifplugd
安装 ifplugd
后,您必须编辑两个配置文件
/etc/default/ifplugd
/etc/ifplugd/action.d/ifupdown
以下示例配置将 ifplugd
配置为在 MLAG 环境中对等 bond 发生故障时关闭所有上行链路。
在文本编辑器中打开
/etc/default/ifplugd
并根据需要配置文件。在保存文件之前添加peerbond
名称。INTERFACES="peerbond" HOTPLUG_INTERFACES="" ARGS="-q -f -u0 -d1 -w -I" SUSPEND_ACTION="stop"
在文本编辑器中打开
/etc/ifplugd/action.d/ifupdown
文件。配置脚本,然后保存文件。#!/bin/sh set -e case "$2" in up) clagrole=$(clagctl | grep "Our Priority" | awk '{print $8}') if [ "$clagrole" = "secondary" ] then #List all the interfaces below to bring up when clag peerbond comes up. for interface in swp1 bond1 bond3 bond4 do echo "bringing up : $interface" ip link set $interface up done fi ;; down) clagrole=$(clagctl | grep "Our Priority" | awk '{print $8}') if [ "$clagrole" = "secondary" ] then #List all the interfaces below to bring down when clag peerbond goes down. for interface in swp1 bond1 bond3 bond4 do echo "bringing down : $interface" ip link set $interface down done fi ;; esac
重启
ifplugd
守护程序以实施更改cumulus@switch:~$ sudo systemctl restart ifplugd.service
注意事项
ifplugd
的默认 shell 是 dash
(/bin/sh
) 而不是 bash
,因为它提供了更快、更灵活的 shell。但是,dash
包含的功能比 bash
少(例如,dash
无法处理多个上行链路)。