前言
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}