WebFaction
Community site: login faq

Technically not a question, more an answer to one I had.

I recently found myself wanting to know how I could set up a subdomain to point to a machine that I owned, pretty much like DynDNS or no-ip would permit.

I dug up in WebFaction's XML-RPC api, only to find out the create_dns_override and delete_dns_override methods. Funny thing, you can call this easily with Ruby.

#! /usr/bin/env ruby
require 'xmlrpc/client'
require 'pp'

# Connect to the server
server = XMLRPC::Client.new2("https://api.webfaction.com/")

# Code to fetch your external ip not included... yet? Contribution would be appreciated
# I'm guessing this could just be a web service determining where you're calling from.
target_ip = cool_method_that_determines_your_wan_ip

# You need to get the response back as the first element is your sessionID, which is used afterwards.
response = pp server.call("login", "your_control_panel_username", "your_control_panel_password")

# First, delete the target override. 
# I don't really care whether it exists or not, I just want to destroy it to create it anew.
# Is it possible just to update a record with "create"? Documentation doesn't say.
pp server.call("delete_dns_override",response[0], "your.domain.com")
pp server.call("create_dns_override",response[0], "your.domain.com", target_ip)
This question is marked "community wiki".

asked 13 Jan '11, 18:44

mrzombie
17159
accept rate: 0%

edited 13 Jan '11, 18:44

The reason I included the method to fetch a target ip is that technically, you'll have to. The way I tried it, I just input my WAN IP after fetching it manually. [edit: I pretty much executed the above in IRB. Also, this script goes in a cron job on your local server (or any machine on your lan, really), and probably should be stored somewhere on your path so you can update it manually should the need arise.]

(13 Jan '11, 18:54) mrzombie

Nice, thanks for sharing!

permanent link

answered 15 Jan '11, 17:42

seanf
12.2k42136
accept rate: 37%

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:

×11
×2

question asked: 13 Jan '11, 18:44

question was seen: 2,687 times

last updated: 15 Jan '11, 17:42

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 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