New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
How to assign MACs to OVH failover IPs (script included)
Any failover IP in OVH requires to be assigned to the given MAC, before that, you need to generate the MAC on the OVH client control panel.
If you only have several IPs, it's fine to do it in the panel, but in case you have a /24 block....
There are API methods from OVH official documents, here I'm just sharing a small trick, you can always choose to use the API requests
Firstly, you need to login into the OVH client control panel, then copy the cookies from your browser.
Secondly, you will need to know the server name as well as the IP subnet prefixes.
Finally, swap the info into the script below (in "{}")and run in any Linux servers.
for ipid in {1..255}
do
curl 'https://www.ovh.com/engine/apiv6/dedicated/server/{Your-Server-Name}/virtualMac' \
-H 'authority: www.ovh.com' \
-H 'accept: application/json, text/plain, */*' \
-H 'content-type: application/json;charset=UTF-8' \
-H 'origin: https://www.ovh.com' \
-H 'referer: https://www.ovh.com/manager/dedicated/' \
-H 'cookie: {Your-Browser-Cookies}' \
--data-raw '{"ipAddress":"{Your-IP-Subnet-Prefixes}.'"$ipid"'","type":"ovh","virtualMachineName":"{Your-IP-Subnet-Prefix}.'"$ipid"'"}' \
--compressed ;
sleep 30
done
Comments
-- encoding: utf-8 --
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import os
import sys
import json
import ovh
serverid = sys.argv[1]
ip = sys.argv[2]
mac = sys.argv[3]
vm = sys.argv[4]
client = ovh.Client(
endpoint='ovh-eu',
application_key='XXXXXXXXXX',
application_secret='XXXXXXXXXXXXXXXX',
consumer_key='XXXXXXXXXXXXXXXXXXXX',
)
client = ovh.Client()
result = client.post('/dedicated/server/%s/virtualMac/%s/virtualAddress' % (serverid,mac),
ipAddress=ip,
virtualMachineName=vm,
)
Pretty print
print json.dumps(result, indent=4)
./ovhmac serverid ipv4 macaddress description
Easiest way is to use API instead of someone kind of developing web browser