UPDATE It seems that the System Preferences GUI _can_ be used to modify the DNS in some circumstances. For some reason, it sometimes does not work and you need to use the command line as described here. You should try the GUI first, it's much easier.

A brief tip on how to re-configure Mac OS X DNS, when the DNS server provided by your network operator via DHCP does not work:

#!/bin/sh
[ "$1" = "" ] && echo "Usage: $0 <dns-server>" && exit
for state in `echo 'list State:/Network/Service/[^/]+/DNS' | /usr/sbin/scutil | /usr/bin/awk '{print $4}'`; do
	(echo "get $state"; echo "d.add ServerAddresses * $1"; echo "set $state") | /usr/sbin/scutil
done

If you name the above script e.g. set-dns, you can override the default DNS server of all your active network connections with Google Public DNS like this:

sudo ./set-dns 8.8.8.8

Detailed explanation

The DNS setting of network interfaces is controlled using the scutil command in Mac OS X. Unfortunately, it cannot be overriden in the System Preferences if it has been set automatically by the DHCP server. So first you need to find the subkey of the appropriate setting with scutil:

$ scutil
> list State:/Network/Service/[^/]+/DNS
  subKey [0] = State:/Network/Service/2C217271-01B2-DEAD-922A-49F8D72EB00B/DNS

When you have the subkey, you can view the current setting:

$ scutil
> show State:/Network/Service/2C217271-01B2-DEAD-922A-49F8D72EB00B/DNS
<dictionary> {
  DomainName : home
  ServerAddresses : <array> {
    0 : 192.168.1.1
  }
}

To finally change the setting, its current value is read as a dictionary, modified and then saved over the old value.

$ sudo scutil
> get State:/Network/Service/2C217271-01B2-DEAD-922A-49F8D72EB00B/DNS
> d.add ServerAddresses * 8.8.8.8
> set State:/Network/Service/2C217271-01B2-DEAD-922A-49F8D72EB00B/DNS
> show State:/Network/Service/2C217271-01B2-DEAD-922A-49F8D72EB00B/DNS
<dictionary> {
  DomainName : home
  ServerAddresses : <array> {
    0 : 8.8.8.8
  }
}

Not very beautiful, but works.