Archive for August, 2012

Querying the DNS by hand

Thursday, August 30th, 2012

Well, almost.

I wanted to get acquainted with using socat for UDP, so here’s something whipped up with the help of DNSPython:


python -c "import dns.message, dns.rdataclass, dns.rdatatype; "\
"print dns.message.make_query(dns.name.Name(['dready', 'org', '']), dns.rdatatype.A).to_wire()" \
| socat - UDP:8.8.4.4:53 \
| python -c "import sys, dns.message; "\
"print '\n'.join(str(m) for m in dns.message.from_wire(sys.stdin.read()).answer)"

Speed up Your SSH Connections for Free

Wednesday, August 8th, 2012

Adding the following directives to your .ssh/config should reduce your SSH connection establishment time significantly:

        ControlMaster auto
        ControlPersist yes
        ControlPath "/tmp/ssh-c-%r@%h:%p"

This works by having all SSH sessions sharing a single “control” connection.

The ControlMaster auto directive tells OpenSSH client to start a control master if one is not already running, otherwise it will reuse a previous one.

The ControlPersist yes directive tells the control master process to continue running in the background even though you’ve exited from the session, allowing subsequent sessions to reuse its connection.

The ControlPath is the control socket rendezvous point for masters and slaves. If you’re on a shared host, you might want to set it to a private location such as in your ~/.ssh/ directory instead of /tmp.

In my case, I stuck these into the wildcard Host section:

Host *
        Compression yes
        ServerAliveInterval 60
        ServerAliveCountMax 5
        ControlMaster auto
        ControlPersist yes
        ControlPath "/tmp/ssh-c-%r@%h:%p"

I’ve always known that OpenSSH had this functionality, but hadn’t bothered to try it out until now and it’s sooo very handy!