游戏联盟分享平台-全自助-免费游戏分享-七玩网
我的世界《记忆之间》一个全新的MMOARPG模式MC-七玩网
独家出售24-70级附魔端授权、完美六职业、农场BOSS挑战、自定义加密RFS、支持称号图片,同时兼容64位与32位系统。-七玩网
蓝易云香港服务器特惠:29元/月尊享1核1G内存10Mbps CN2线路,大带宽首选,品质推荐,信赖之选!-七玩网

原神自动修改公网IP地址 修改成功自动发送邮件给自己,新人首贴

本帖最后由 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 链接到服务器

  1. cd root

复制代码 新建个getIp.sh,
recentIp.log

  1. vim getIp.sh

复制代码

  1. #!/bin/bash
  2. IP=$(curl icanhazip.com)
  3. LASTIP=$(cat /root/recentIp.log)
  4. sleep 2s
  5. if [ -z “$IP” ];then
  6.         echo ‘从myip.dnsomatic.com获取公网ip失败,正在尝试其他方式。。。’
  7.         IP=$(curl icanhazip.com)
  8.         sleep 2s
  9.         if [ -z “$IP” ];then
  10.                 echo ‘从icanhazip.com获取公网ip失败,正在尝试其他方式。。。’
  11.                 IP=$(curl cip.cc)
  12.         fi
  13. fi
  14. sleep 2s
  15. echo ‘IP=’$IP
  16. echo ‘LASTIP=’$LASTIP
  17. if [ “$IP”x != “$LASTIP”x ];then
  18.           echo ‘ip地址有更新’
  19.           echo $IP > /root/recentIp.log
  20.              cd /root/genshin/srv/dbgate/conf
  21.                 sed -i “s/$LASTIP/$IP/” *.xml
  22.                 cd /root/genshin/srv/dispatch/conf
  23.                 sed -i “s/$LASTIP/$IP/” *.xml
  24.                 cd /root/genshin/srv/gameserver/conf
  25.                 sed -i “s/$LASTIP/$IP/” *.xml
  26.                 cd /root/genshin/srv/gateserver/conf
  27.                 sed -i “s/$LASTIP/$IP/” *.xml
  28.                 cd /root/genshin/srv/muipserver/conf
  29.                 sed -i “s/$LASTIP/$IP/” *.xml
  30.                 cd /root/genshin/srv/multiserver/conf
  31.                 sed -i “s/$LASTIP/$IP/” *.xml
  32.                 cd /root/genshin/srv/nodeserver/conf
  33.                 sed -i “s/$LASTIP/$IP/” *.xml
  34.                 cd /root/genshin/srv/pathfindingserver/conf/
  35.                 sed -i “s/$LASTIP/$IP/” *.xml
  36.                 cd /root/genshin/srv/oaserver/conf/
  37.                 sed -i “s/$LASTIP/$IP/” *.xml
  38.                 cd /root/genshin/srv/tothemoonserver/conf
  39.                 sed -i “s/$LASTIP/$IP/” *.xml
  40.                 cd /root/genshin/srv/sdkserver
  41.                 sed -i “s/$LASTIP/$IP/” *.json
  42.                 echo $IP | mail -s 公网ip [email protected]
  43.         
  44. else
  45.         echo ‘ip地址没更新’
  46. fi

复制代码
然后设置定时任务执行,如下:

  1. crontab -e

复制代码

  1. */10 * * * * /root/getIp.sh

复制代码
注意:前提条件是linux系统已经安装了mailx,请自行检查,如果没安装,执行命令

  1. yum -y install mailx

复制代码
即可安装


至此,每隔10分钟,自动获取最新公网ip,如果有更新,发送到目标邮箱。


新人发帖,多多关照




© 版权声明
THE END
文章不错?点个赞呗
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容