juniper srx重启后自动修改配置
在配置模式下通过命令run start shell 进入shell 模式
root@id404# run start shell root@id404%
首先确定脚本存放的位置 ,我将脚本放置在/cf/var/log/change-config.sh 也可以放置在其它文件夹,但需要确保设备重启后文件夹不会清空。有部分文件夹会在设备重启后清空的
脚本内容:
#!/bin/sh
#author:id404
echo 'STARTING sleep 300s to complete boot process' >> /var/log/updatevpn-date.log logger "STARTING sleep 300s to complete boot process" sleep 300 echo 'after 300s' >> /var/log/updatevpn-date.log logger "AFTER 300s" logger "STARTING configuration using script" date >> /var/log/updatevpn-date.log echo "STARTING configuration using script" >> /var/log/updatevpn-date.log /usr/sbin/cli -c 'configure;delete security ike gateway id404-sdwan-gw address;set security ike gateway id404-sdwan-gw address vpn.id404.cn;commit comment "Commit by script updatevpn address"'
修改定时任务内容
root@id404% crontab -e
@reboot /bin/sh /cf/var/log/change-config.sh