If like me you do not have a fixed IP addres, you may have to update a DNS record.
And if you use a VPN, you want to update the DNS record with your real IP address.
Here is a bootscript to do that in Python.
you need 2 things:
The address of the internet service which will display your IP
( http://ipinfo.io/ip in my case )
The gateway to use to directly connect to this service
( usually the default gateway when your are not connected through the VPN )
#!python import socket from pyroute2 import IPRoute def set_route(dest, gw): resolver = socket.gethostbyname(dest) ip = IPRoute() get_to = ip.get_routes(dst=resolver) for f in get_to['attrs']: if f == 'RTA_GATEWAY': gw_curr = f if gw_curr != gw: ip.route('add', dst=resolver, gateway=gw, mask=32) set_route('ipinfo.io', 192.168.0.254)
This code will update the routes to bypass the VPN routes, and your DNS will be updated with the correct IP address.