本帖最后由 lb1217 于 2023-1-9 13:49 编辑
原神想要外网链接,必须修改
/root/genshin/srv/dbgate/conf
/root/genshin/srv/dispatch/conf
/root/genshin/srv/gameserver/conf
/root/genshin/srv/gateserver/conf
/root/genshin/srv/muipserver/conf
/root/genshin/srv/multiserver/conf
/root/genshin/srv/nodeserver/conf
/root/genshin/srv/oaserver/conf
/root/genshin/srv/pathfindingserver
/root/genshin/srv/oaserver/conf
/root/genshin/srv/sdkserver
/root/genshin/srv/tothemoonserver/conf
以上目录的IP地址。
首先用FinalShell 链接到服务器
- cd root
复制代码 新建个getIp.sh,
recentIp.log
- vim getIp.sh
复制代码
- #!/bin/bash
- IP=$(curl icanhazip.com)
- LASTIP=$(cat /root/recentIp.log)
- sleep 2s
- if [ -z “$IP” ];then
- echo ‘从myip.dnsomatic.com获取公网ip失败,正在尝试其他方式。。。’
- IP=$(curl icanhazip.com)
- sleep 2s
- if [ -z “$IP” ];then
- echo ‘从icanhazip.com获取公网ip失败,正在尝试其他方式。。。’
- IP=$(curl cip.cc)
- fi
- fi
- sleep 2s
- echo ‘IP=’$IP
- echo ‘LASTIP=’$LASTIP
- if [ “$IP”x != “$LASTIP”x ];then
- echo ‘ip地址有更新’
- echo $IP > /root/recentIp.log
- cd /root/genshin/srv/dbgate/conf
- sed -i “s/$LASTIP/$IP/” *.xml
- cd /root/genshin/srv/dispatch/conf
- sed -i “s/$LASTIP/$IP/” *.xml
- cd /root/genshin/srv/gameserver/conf
- sed -i “s/$LASTIP/$IP/” *.xml
- cd /root/genshin/srv/gateserver/conf
- sed -i “s/$LASTIP/$IP/” *.xml
- cd /root/genshin/srv/muipserver/conf
- sed -i “s/$LASTIP/$IP/” *.xml
- cd /root/genshin/srv/multiserver/conf
- sed -i “s/$LASTIP/$IP/” *.xml
- cd /root/genshin/srv/nodeserver/conf
- sed -i “s/$LASTIP/$IP/” *.xml
- cd /root/genshin/srv/pathfindingserver/conf/
- sed -i “s/$LASTIP/$IP/” *.xml
- cd /root/genshin/srv/oaserver/conf/
- sed -i “s/$LASTIP/$IP/” *.xml
- cd /root/genshin/srv/tothemoonserver/conf
- sed -i “s/$LASTIP/$IP/” *.xml
- cd /root/genshin/srv/sdkserver
- sed -i “s/$LASTIP/$IP/” *.json
- echo $IP | mail -s 公网ip [email protected]
- else
- echo ‘ip地址没更新’
- fi
复制代码
然后设置定时任务执行,如下:
- crontab -e
复制代码
- */10 * * * * /root/getIp.sh
复制代码
注意:前提条件是linux系统已经安装了mailx,请自行检查,如果没安装,执行命令
- yum -y install mailx
复制代码
即可安装
至此,每隔10分钟,自动获取最新公网ip,如果有更新,发送到目标邮箱。
新人发帖,多多关照
没有回复内容