• Welcome to LiuJason's Blog!

OVH批量给额外IP(Failover IP)设置virtual Mac | 一键脚本

Linux笔记 Jason 3 months ago (06-27) 79 Views 0 Comments QR code of this page
文章目录[隐藏]

前言

OVH的IP是真的便宜,一次性支付2欧的安装费就能长期免费使用,但是配置IP的时候需要初始化mac,而官网的GUI又不支持批量操作….

干货

虽然看到有API文档,但是嫌麻烦没去看,于是用chrome抓了一下请求然后写了个简单的bash脚本自动完成。
前提条件:登录ovh网页,然后提取cookies

for ipid in {1..255}
do
	curl 'https://www.ovh.com/engine/apiv6/dedicated/server/【你的服务器名】/virtualMac' \
	  -H 'authority: www.ovh.com' \
	  -H 'sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"' \
	  -H 'x-ovh-manager-version: cobalt-burro-2' \
	  -H 'x-ovh-manager-navigation-id: kqf98yqm' \
	  -H 'x-ovh-manager-page: app.ip.dashboard' \
	  -H 'sec-ch-ua-mobile: ?0' \
	  -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' \
	  -H 'content-language: en_GB' \
	  -H 'accept: application/json, text/plain, */*' \
	  -H 'x-ovh-manager-request-id: 1624802214805-34' \
	  -H 'content-type: application/json;charset=UTF-8' \
	  -H 'origin: https://www.ovh.com' \
	  -H 'sec-fetch-site: same-origin' \
	  -H 'sec-fetch-mode: cors' \
	  -H 'sec-fetch-dest: empty' \
	  -H 'referer: https://www.ovh.com/manager/dedicated/' \
	  -H 'accept-language: en,zh-CN;q=0.9,zh;q=0.8,zh-TW;q=0.7,de;q=0.6,und;q=0.5,ja;q=0.4' \
	  -H 'cookie: 【把cookies贴进来】' \
	  --data-raw '{"ipAddress":"【你的IP前缀】.'"$ipid"'","type":"ovh","virtualMachineName":"【你的IP前缀】.'"$ipid"'"}' \
	  --compressed ;
	sleep 30
done

使用效果:

{"function":"addVirtualMac","startDate":"2021-06-27T16:12:56+02:00","lastUpdate":"2021-06-27T16:12:56+02:00","comment":"Create a virtual mac for ip 【IP地址】","status":"init","doneDate":null,"taskId":261404849}

This article is under CC BY-NC-SA 4.0 license.
Please quote the original link:https://www.liujason.com/article/1166.html
Like (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址