微软dhcp服务器主备失效,[自定义服务]dhcp故障转移服务,使路由器为dhcp备机

#!/bin/sh /etc/rc.common

# Copyright (C) 2013-2014 ****email****

START=99

STOP=11

#DHCP Server's IP

DS=192.168.0.102

#Refer to /etc/config/dhcp

InterfaceName=lan

CheckInterval=27

use_syslog=1

use_varlog=1

log=/var/log/dhcp_failover.csv

PID=/var/run/dhcp_failover.pid

lastDSstatus=-1

dhcp_failover_logger()

{

if [ "$use_syslog" = 1 ]

then

logger -t dhcp_failover[$] $*

fi

if [ "$use_varlog" = 1 ]

then

echo $*>>$log

fi

}

start()        {

if [ -e $PID ] ; then

dhcp_failover_logger $(date +"%F,%T"),Dhcp_failover is already running.

else

echo [        DISCUZ_CODE_2        ]gt;$PID

dhcp_failover_logger $(date +"%F,%T"),Process $ is starting.

while [ true ]

do

ping -w 2 $DS >/dev/null

DSstatus=$?

if [ $lastDSstatus -ne $DSstatus ] ; then

if [ $lastDSstatus -ne -1 ] ; then

dhcp_failover_logger $(date +"%F,%T"),The status of $DS has been changed.

fi

NewIgnoreFlag=$DSstatus

uci get dhcp.$InterfaceName.ignore

OldIgnoreFlag=$?

if [ $OldIgnoreFlag -ne $NewIgnoreFlag ] ; then

if [ $NewIgnoreFlag -eq 0 ] ; then

uci set dhcp.$InterfaceName.ignore=1

else

if [ $NewIgnoreFlag -eq 1 ] ; then

uci delete dhcp.$InterfaceName.ignore

fi

fi

dhcp_failover_logger $(date +"%F,%T"),Setting $(uci changes dhcp).

uci commit dhcp

/etc/init.d/dnsmasq restart

sleep 1

dhcp_failover_logger $(date +%F,%T),Dnsmasq\'s pid is $(cat /var/run/dnsmasq.pid).

fi

fi

lastDSstatus=$DSstatus

sleep $CheckInterval

done

fi

}

stop() {

if [ -e $PID ] ; then

kill -9 $(cat $PID)

rm -f $PID

dhcp_failover_logger $(date +"%F,%T"),Dhcp_failover has been killed.

else

dhcp_failover_logger $(date +"%F,%T"),Dhcp_failover is NOT running.

fi

}

restart() {

stop

dhcp_failover_logger $(date +"%F,%T"),Dhcp_failover is restarting.

start

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值