Archive

Posts Tagged ‘dns’

DNS for bash

March 31st, 2008

Today, I decided I wanted a network service that propagated variables and aliases to every login shell that subscribed to it. This is dangerous on a large scale, but perfectly acceptable on my small home network where everyone trusts everyone else.

First, I got Camping installed, bringing back fond memories of Ruby development. I then copied off the blog example, and created TreeHugger, a 427 line script that provides a web interface to edit the variables, and a plain text output for the shells to source.

This script, when run, allows some simple MVC actions to an sqlite3 database.

Example Screenshot

As you can see, I have some aliases here I want to send to all the subscribing hosts. Eventually, I want to add some detection functionality to the database (mostly reverse DNS lookups for host rule referencing). I just have to access /out to get my desired output:


# Treehugger Configuration
# Aliases
alias ai='sudo apt-get install'
alias aup='sudo apt-get update'
alias aug='sudo apt-get upgrade'

# Environment Variables

Now, to get this into bash. I looked into making the date command spit out pretty unique timestamps. Turns out you can do this with the nanoseconds format:


$ date +%s%N
1206926780157462141

I made it so wget saves the treehugger config to a tempfile using the somewhat random seed above as a filename suffix, and then I have my shell source it:


FILENAME=/tmp/treehugger-`date +%s%N`; 2>/dev/null wget -O $FILENAME  http://rofl.who/treehugger/out && source $FILENAME && rm $FILENAME

And now I have nice aliases on my laptop served up from my desktop as fresh as the shell:


hank@davros:~$ alias
alias ai='sudo apt-get install'
alias aug='sudo apt-get upgrade'
alias aup='sudo apt-get update'
alias ls='ls --color=auto'


Uncategorized , , , , , , , ,

Setting up DNS on my network

March 25th, 2008

I decided to set up bind9 today on my Gutsy server. It wasn’t too painful after I finally found some posts from someone who knew what they were doing (2 tutorials I read contained invalid configurations…).

First, you install bind:


sudo apt-get install bind9

Read more…


Uncategorized , ,

DNS Catch-all for OpenID

February 20th, 2007

We were trying to get our OpenID server working today, and we found that we needed to make a catch-all DNS entry to do it. That way, things like hank.myopenid.url would work. Here’s one way to do it:


*.yourdomain.com. IN A 111.111.111.111

But, we ended up using a CNAME instead:


UPDATE ADD *.yourdomain.com. 86400 IN CNAME yourdomain.com

Then in your Apache virtual hosts directive add a wildcard alias like this


ServerAlias *.yourdomain.com

Incredible.


Uncategorized , ,

DNS Mania

September 2nd, 2006

Well, I was stumbling today and found OpenDNS. I
was excited to find that I could make it coexist with OpenNIC in my dhclient
configuration. Here’s the resultant line that makes all this magic happen:


prepend domain-name-servers 63.226.12.96, 208.67.222.222, 208.67.220.220;

So now, when I use dhcp to grab an IP, I end up prepending these nameservers
onto my resolv.conf. OpenDNS makes spam sites and domain squatters disappear.
And it makes the average request a lot faster.

Yesterday, bish0p and I sat down and started
work on MyDNS. It turns out that the db structure
isn’t all that bad, so it will be fairly straightforward to build a
Rails/Camping interface for it. I already started one in Camping called
Beacon. I was going to name it ChunkyBeacon, but #camping decided
against that.

In other news, I’m going to leave Fairbanks for a while soon. It will be
exciting to go on this adventure into the real world for four months.

Uncategorized , , , ,