Brier's Blog

/dev/brier/mark

Sick Beard OS X

Sick Beard automatically searches NZB index and torrent sites for your favourite shows and downloads and organises them for you! It makes downloading a series an absolute breeze!

You’ll need a working Sabnzbd+ installation if you want to download from NNTP servers. You’ll also need a premium NNTP account. I got a cheap one from Astranews.

The Ultimate Mac media rig!

Hardware

  • Onkyo TX-SR606 A/V Amplifier
  • Mordaunt Short 5.1 Avant Premiere system
  • Philips 42″ 1080p HDTV
  • Mac Mini 3,1 (upgraded) Core2Duo 2.66GHz, 2GB RAM, 80GB SSD
  • MacBook Air 4,1 11″ Core i7 1.8GHz, 4GB RAM, 128GB SSD
  • 2x iPhone 3GS
  • 1.5TB USB2 HDD (connected to MacMini)
  • Virgin Superhub WiFi Router

Connectivity

  • TOSLink to MiniTOSLink Digital Optical audio lead (Mac Mini -> Onkyo)
  • DVI to HDMI cable (Mac Mini -> Onkyo)
  • HDMI (Onkyo -> HDTV)
  • Gigabit Ethernet (Mac Mini)
  • 802.11n WiFi (MacBook Air / iPhones 3GS)
  • 100M Virgin Broadband

Software

 

Hello world!

Obligatory blogpost number 1!

Eggs

Eggs for breakfast YAY!

]]>

Jgit and Amazon s3

Excellent link here about using jgit to publish your git repo’s to amazon s3 …

http://blog.spearce.org/2008/07/using-jgit-to-publish-on-amazon-s3.html

]]>

An Intro to Sed

http://www.grymoire.com/Unix/Sed.html

]]>

etckeeper – /etc in git repository

Very useful indeed this … it stores your /etc/ directory in a git repo and even stores changes before apt-get runs!

http://kitenet.net/~joey/code/etckeeper/

]]>

Vim files over scp

Wow, what a useful tip!

Now I can have my local syntax highlighting and .vimrc options whilst editing files on any one of our servers without having to push any of my vim config!

http://vim.wikia.com/wiki/Edit_remote_files_locally_via_SCP/RCP/FTP

]]>

Local DNS Setup

Ok, this post is about the local DNS server I setup for myself. the motivation behind this was three-fold…

One problem I have is that whilst we have forward and reverse internal DNS setup for all our servers in the data canters (our config management system relies on it), many of the reverse zones are not delegated to the office DNS and as such, reverse lookups fail when records exist. I can point my resolv.conf elsewhere (data-centre DNS servers), but then lookups for office-based stuff fails.

Secondly, we use a Cisco VPN at work, which I have been connecting to via vpnc. Although only traffic destined for servers on the VPN actually travels down the tunnel (with other web traffic avoiding it) … vpnc (unless told not to) overwrites /etc/resolv.conf, which in turn means ALL DNS queries go down the VPN. This is so that DNS lookups of server addresses in our internal TLD (.tmcs) actually get resolved.

Thirdly, I often use my laptop out and about and it doesn’t make me feel hugely comfortable to (in most cases) have my DNS queries hit some LAN resolver which logs queries and suchlike.

So, I decided I would run my own local caching DNS server and configure different DNS server destinations for different domains. Then, when I have finished working from home, forget to close the VPN connection, and then browse to www.a-dodgy-website.com, there’s no trail left of my visit there left in the VPN logs etc. Also, I want to force my system to ALWAYS use 127.0.0.1 for lookups, and configure my DNS resolver to use the OpenDNS DNS servers for their non *.tmcs lookups.

Read on for how it’s done!

OK, so the introduction interested you?! Well, fortunately this is pretty easy to setup. First, let’s install some packages. We’re going to need a DNS server, but instead of installing bind, we’re going to use dnsmasq as it’s easy to setup and more suited to a caching setup rather than a full-blown DNS server.

$ apt-get install dnsmasq

Also, we need some way of making sure resolv.conf retains our setup. The badly-named package resolvconf does this…

$ apt-get install resolvconf

Now we need to configure dnsmasq, so lets start from scratch. Move the (heavily commented) default config file and let’s create a new one…

$ mv /etc/resolv.conf /etc/resolv.conf/default

Now, lets create the config file …

$ vim /etc/dnsmasq.conf

… and start with some basic config options

no-resolv # forces dnsmasq to NOT get it's upstream servers from /etc/resolv.conf
no-poll # more of the same ... do NOT poll /etc/resolv.conf for changes
listen-address=127.0.0.1 # Only listen on the loopback address
no-dhcp-interface=lo # disable dnsmasq's built-in DHCP server
bind-interfaces # Makes sure we only really do listen on 127.0.0.1:53
no-hosts # don't process and therefore use /etc/hosts

Well, that’s the bulk of the options, the rest is your server definitions, which will depend on your own setup. You’ll probably want some specific DNS servers for local/internal DNS and then send everything else to OpenDNS (or some other public DNS service) here are some of my options explained…

server=/.office.tmcs/172.28.10.32server=/.office.tmcs/172.28.11.32
server=/.corp/172.28.10.32server=/.corp/172.28.11.32

Ok, the above sends forward lookups for *.office.tmcs and *.corp to my local office DNS servers

server=/.tmcs/192.168.114.184server=/.tmcs/192.168.114.185

This sends everything all forward lookups under *.tmcs (which don’t get matched above) to the DNS servers in our admin cluster

server=208.67.222.222server=208.67.220.220

And this line sends all other queries to the public OpenDNS servers.

server=/10.in-addr.arpa/192.168.114.184server=/10.in-addr.arpa/192.168.114.185
server=/1-62.56.104.209.in-addr.arpa/192.168.114.184server=/1-62.56.104.209.in-addr.arpa/192.168.114.185

These are for the reverse zones. I got these from the “TargetNetworks” part of my vpnc config file. The first two of these (10.in-addr.arpa) sends all reverse lookups for 10.*.*.*, or 10.0.0.0/8 to our DNS servers in the admin cluster, which can handle those queries. The second two do the same, however they demonstrate how to specify more complex subnets. 1-62.56.104.209.in-addr.arpa relates to IP addresses in the range 209.104.56.1-62 or 209.104.56.0/26

For now, we’re just going to add another config option, temporarily so we can see things working as we expect.

log-queries

This will log ALL queries and where dnsmasq sends them, to /var/log/messages. Save that file and go back to your bash prompt.

Now, we need to add an option to our vpnc config file, so that it doesn’t overwrite our resolv.conf when it sets up the tunnel (your vpnc config filename/location will likely differ)…

$ echo "DNSUpdate no" >> /etc/vpnc/lca-internal.conf

And of course we need to setup /etc/resolv.conf to point locally, so edit that file…

$ vim /etc/resolv.conf

nameserver 127.0.0.1

Ok, save that file. Now we’re going to make sure when /etc/resolv.conf DOES get changed (by various programs such as NetworkManager), that it retains our local resolver. We just need to edit one file for that…

$ vim /etc/resolvconf/resolv.conf.d/base
nameserver 127.0.0.1

Save that one. All we need to do now is start/restart dnsmasq…

$ service dnsmasq restart

… and start our vpn (this might differ for you)

$ vpnc-connect /etc/vpnc/lca-internal.conf

And now we can open a terminal and tail the logs…

$ tail -f /var/log/messages

… Then open another terminal and try some queries, making sure they

  • Are hitting your local resolver on 127.0.0.1
  • Are being sent to the destinations you configured
  • Are being cached (try same query a few times)

And when done, remove the query log, restart dnsmasq, and you’re good to go…

$ vim /etc/dnsmasq.conf

Remove this line

log-queries

And restart

$ service dnsmasq restart

]]>

Syntax highlighting in less

http://linux-tips.org/article/78/syntax-highlighting-in-less

]]>