WebFaction
Community site: login faq
1
2

I'm looking for a simple WebFaction API script which can be used to update a domain (home.mydomain.com) to my home IP address on an hourly basis. I'll call this from cron on my local machine.

asked 23 Oct '13, 19:22

ryans ♦♦
5.0k93160
accept rate: 43%


Sure, here's a script you can use:

#!/usr/bin/env python

import sys
import xmlrpclib
import urllib2

wf_account = 'myWfAccount'           # Your WebFaction Account Name
wf_password = 'myWfPassword'         # Your WebFaction Control Panel Password
home_domain = 'home.mydomain.com'    # The Domain to update (must exist in the Control Panel)

server = xmlrpclib.ServerProxy('https://api.webfaction.com/')
(session_id, account) = server.login(wf_account, wf_password)

home_override = None
for override in server.list_dns_overrides(session_id):
    if override['domain'] == home_domain:
        home_override = override
        break

my_ip = urllib2.urlopen('http://ip.ryansanden.com/').read().strip()

if home_override and home_override['a_ip'] == my_ip:
    sys.exit(0)

if home_override:
    server.delete_dns_override(session_id, home_domain, home_override['a_ip'])

server.create_dns_override(session_id, home_domain, my_ip)

You can then save this to your home directory. Be sure to keep it secure since it contains your password:

chmod 600 ~/cron/home_dns_override.py

Then call it from cron on an hourly basis:

0 * * * * /usr/bin/python ~/cron/home_dns_override.py

Hope that helps!

permanent link

answered 23 Oct '13, 19:27

ryans ♦♦
5.0k93160
accept rate: 43%

It would be nice to use OAuth2 or something similar to avoid having to put the password in a text file. Any plans for that?

(09 Apr '14, 10:24) pepevi

There are no plans for that at this time, but I'll open an internal feature request for it.

(09 Apr '14, 21:37) seanf

I've used this script and while I see the IP address for "home.mydomain.com" change in the control panel, it doesn't seem to change the ip address served by DNS when I try "host home.mydomain.com." It's been a week, so it's had time to propagate. I'm not sure what's going on.

(25 May '14, 13:15) greg9799

I would verify that you are using our nameservers first. Once that is confirmed then you may need to open a support ticket so we can troubleshoot directly.

(25 May '14, 13:20) aaront ♦♦

Thanks. I get the new address with "host home.mydomain.com ns1.webfaction.com" but I get the old address with my ISP's (verizon's) dns server or with google (8.8.8.8). Strangely, AT&T's server (68.94.156.1) gives the new address. I guess I'll open a support ticket.

(25 May '14, 22:20) greg9799

How long did you wait for global propagation?

(25 May '14, 23:34) johns

It's been a week.

(26 May '14, 01:52) greg9799

Have you tested the domain on all four WebFaction nameservers?:

host home.mydomain.com ns1.webfaction.com
host home.mydomain.com ns2.webfaction.com
host home.mydomain.com ns3.webfaction.com
host home.mydomain.com ns4.webfaction.com

If one or more of the WebFaction nameservers is wrong, please open a support ticket with WebFaction and we can regenerate the DNS for you.

If all of the WebFaction nameservers return the correct DNS value, then you'll need to open a support ticket with your ISP to see why their DNS server is not updating.

(26 May '14, 02:08) ryans ♦♦

Thanks again. ns1-ns3 have the new address and ns4 has the old one.

(26 May '14, 11:28) greg9799
showing 5 of 9 show 4 more comments

Hello,

The DNS synchronization was stuck on NS4, hence the problem.

The resolution was to regenerate the DNS records for that domain name on NS4.

If you experience further issues then please do not hesitate to reopen your ticket.

Sincerely,

Valentin I.
WebFaction Support
--
WebFaction - Smarter web hosting
http://webfaction.com
http://twitter.com/webfaction - http://facebook.com/webfaction

permanent link

answered 26 May '14, 12:35

valentini
2614
accept rate: 28%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×104
×81
×3

question asked: 23 Oct '13, 19:22

question was seen: 5,335 times

last updated: 26 May '14, 12:35

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM