7/31/09

Happy Girls

I will be watching Tonight's Super Girls (or Happy Girls, as it's called now). I don't know why I watch it. I never watched American Idols or any other pop contest shows. And I absolutely hate the most populor one of previous super-girls winner - Li Yuchun.

But since I watched this year's happy-girls one night with wife, I got hooked. Maybe it's just the pretty girls I'd like to watch. I told a co-worker the other day I like Happy-girls, she said I'd have become dirty middle-aged man (龌龊中年男人). Is that the reason? Ouch..

I am rooting for Liu Xijun 刘惜君. (big pic)


I also like Tan Lina 谈莉娜, she's very pretty. (pic)
I like Li Xiaoyun 李宵云 too (video), but she's not good-looking. Huang ying's good too, but her voice style gets old after a while. I really don't care for other girls.

Here's a video of Liu from youtube singing "伤痕". In my opinion, it's better than Lin yilian's original.


7/30/09

set up geo dns (geodns) on Fedora using geoipdns pt 2

Here I describe the steps of set up Geoipdns (a Tinydns fork at does geo dns). First following these steps here to set up Tinydns. Even though Geoipdns is a fork, it doesn't provide the configuration programs such as tinydns-conf that's in Tinydns. So it's much easier to set up Geoipdns after we already have Tinydns set up.

You can read Geoipdns document on http://pub.mud.ro/wiki/Geoipdns.
Here are quick steps:
$yum install inotify-tools-devel
#geoipdns use libinotifytools.

$mkdir vdns
$cd vdns/
$wget http://pub.mud.ro/~cia/files/vdns-src.tgz
$tar xfz vdns-src.tgz
$vi conf-cc
#Add " -include /usr/include/errno.h" to the first line of conf-cc

$LOCAL_CFLAGS="-DUSE_LOCMAPS -DUSE_SFHASH -DUSE_TOUCH_RELOADS -DDEBUG_MODE -DHAVE_MMAP_READAHEAD"
$make
$mkdir /usr/local/apps
$./install
$cp -rp /usr/local/apps/vdns/bin/* /usr/local/bin/
The last step is to allow us access vdnsd vdnsdb without add to PATH.

Now geoipdns is installed. Next we need to configure it so it does geo dns.
$cd /etc/tinydns
$cp run run.tinydns #backup run
$vi run
#inside run, we change /usr/local/bin/tinydns to/usr/local/bin/vdnsd

$cd root
$vi Makefile
#inside Makefile we change tinydns-data to vdnsdb

$make
$svc -t /service/tinydns

Now vdnsd should be running, use "ps -ef" to see that vdnsd is running tinydns is not, but you still should see "supervise tinydns".
Do some dig to make sure everything still works just like Tinydns is running.

Now you need to query the server from at least 2 different locations, otherwise you don't know if geodns works or not.
If you set up dns on local network, such as 192.168.1.0, you can put IP's of local machines in "data" and test geodns from these local machine.
If you have a world facing DNS server and you want to test geodns, you can put the IP's of your home, work, colocated server, or VPS in data, then test dns from those locations.

However if you want to test it fast at where you are, you are also in luck, because there're several online dig sites you can use. I will use 2 such sites as examples:
http://dig.menandmice.com/knowledgehub/tools/dig ip is 207.57.2.84
http://www.subnetonline.com/pages/network-tools/online-dig.php ip is 85.17.250.238
Note these Ip's are as of this writing. If they have changed at the time of your testing, you need to change them too in your data file.

Now the data. Suppose your DNS server name is ns1.myserver.com (replace it with your real dns server name), add these to your /etc/tinydns/root/data file:
%onlinedig1:207.57.2.84:32
%onlinedig2:85.17.250.238:32
.example.com::ns1.myserver.com:259200
+www.example.com:1.1.1.1:3600::onlinedig1
+www.example.com:2.2.2.2:3600::onlinedig2
+www.example.com:3.3.3.3:3600::nomatch
Do a "make" to update the data hash.

Now you can start testing. First do a "dig @ns1.myserver.com www.example.com" locally. It should say 3.3.3.3. Then go to http://dig.menandmice.com/knowledgehub/tools/dig , enter name server "ns1.myserver.com", enter domain name "www.example.com", click "perform query", it should say 1.1.1.1. Now do the same on http://www.subnetonline.com/pages/network-tools/online-dig.php, it should say 2.2.2.2.
If they display correct fake information, your geo dns works.

Next you need to add real IP location data and setup geo dns for your real domains.
I will talk about this in another post.

7/29/09

Why geo dns - setting up geodns on fedora part 1

First of all, what is geodns? Let's look at an example. The following show the outputs of dig and ping on www.google.com from 3 different geographical locations.
First from Dallas:

270 06:13 PM wang@ns1)dig www.google.com +short
www.l.google.com.
74.125.47.99
74.125.47.103
(truncated)
271 06:13 PM wang@ns1)ping -c 2 www.google.com
PING www.l.google.com (74.125.47.99) 56(84) bytes of data.
64 bytes from yw-in-f99.google.com (74.125.47.99): icmp_seq=1 ttl=54 time=21.2 ms
64 bytes from yw-in-f99.google.com (74.125.47.99): icmp_seq=2 ttl=54 time=21.0 ms
Next from Xi'an, China:
[wang@www ~]$ dig www.google.com +short
www.l.google.com.
64.233.189.104
64.233.189.147
64.233.189.99
[wang@www ~]$ ping -c 2 www.google.com
PING www.l.google.com (64.233.189.147) 56(84) bytes of data.
64 bytes from hk-in-f147.google.com (64.233.189.147): icmp_seq=1 ttl=242 time=45.7 ms
64 bytes from hk-in-f147.google.com (64.233.189.147): icmp_seq=2 ttl=242 time=45.8 ms
Finally from Zhejiang China:
137 03:06 PM wang@cn)dig www.google.com +short
www.l.google.com.
66.249.89.99
66.249.89.104
66.249.89.147
138 03:06 PM wang@cn)ping -c 2 www.google.com
PING www.l.google.com (66.249.89.99) 56(84) bytes of data.
64 bytes from jp-in-f99.google.com (66.249.89.99): icmp_seq=1 ttl=243 time=47.4 ms
64 bytes from jp-in-f99.google.com (66.249.89.99): icmp_seq=2 ttl=243 time=47.4 ms
You can see the IP's for www.google.com from these locations are different. The reason for this is that Google want to send www.google.com visitors to their nearest web servers. Why? you might ask. Because of network latency. Here's output from pinging US google server from China:
[wang@www ~]$ ping 74.125.47.99 -c 2
PING 74.125.47.99 (74.125.47.99) 56(84) bytes of data.
64 bytes from 74.125.47.99: icmp_seq=1 ttl=44 time=258 ms
64 bytes from 74.125.47.99: icmp_seq=2 ttl=44 time=261 ms
So the ping time is >10 times as long as ping time from within US. If Google doesn't have servers in China (or hk, jp, or whatever closer to China), the experience of Chinese www.google.com visitors will be really bad (long response time, slow page load).

The 3 popular DNS software (bind, powerdns, tinydns) all have geo capability, either with patch, backend, or in tinydns case, a fork called geoipdns. I have been using Tinydns for several years and very satisfied with its ease of use and performance. So I stick with Tinydns for my geodns.
The geodns fork of Tinydns is called geoipdns, it's written by Adrian Ilarion Ciobanu.
I will talk about how to set up Geoipdns in the next post.

Set up Tinydns on Fedora

Installing Tinydns (djbdns) on Fedora consists of 4 steps:
1, Install daemontools
2, Install ucspi-tcp
3, Install djbdns
4, configure tinydns


Step 1: Daemontools
First of all, make sure we have all the packages that's needed:
yum install gcc gcc-c++ make flex bison # etc.
This will install all the compilers, kernel-headers, tools and stuff.
Then
mkdir daemontools
cd daemontools
wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
tar xvfz daemontools-0.76.tar.gz
cd admin/daemontools-0.76/
vi compile/conf-cc #add " -include /usr/include/errno.h" at the end of 1st line
./package/install
cd /command
\rm * #get rid of links, we will use actual excutables here
cp -rp /root/daemontools/admin/daemontools/command/* .
vi /etc/inittab #get rid of that svscanboot line because it's not used from fc9
vi /etc/event.d/svscan #create this new file

The content of this file /etc/event.d/svscan is:
start on runlevel [2345]
stop on runlevel [016]
respawn
exec /command/svscanboot
Now daemontools setup is complete. Do a "ps -ef" to see if svscan is running. If not, manually start it, or reboot.

Step 2: ucspi-tcp
This is simple:
mkdir ucspi-tcp
cd ucspi-tcp/
wget http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz
tar xvfz ucspi-tcp-0.88.tar.gz
cd ucspi-tcp-0.88
vi conf-cc # put " -include /usr/include/errno.h" at the end of 1st line
make
./install


Step 3: djbdns
This is quick too:
mkdir djbdns
cd djbdns/
wget http://cr.yp.to/djbdns/djbdns-1.05.tar.gz
tar xvfz djbdns-1.05.tar.gz
cd djbdns-1.05
vi conf-cc # add " -include /usr/include/errno.h" to the 1st line
make
./install


Step 4: configuration
I will only tinydns here, setting up dnscache is very similiar to setting up tinydns.
useradd –s /bin/false tinydns
useradd –s /bin/false dnslog
tinydns-conf tinydns dnslog /etc/tinydns your_external_ip
ln -s /etc/tinydns /service/
svstat /service/tinydns

That's it, do "svstat /service/tinydns" again, it should show the seconds it's up keep increasing. If not, like for example it stuck at 0 or 1 second, then your setup is not correct.
To debug the problem, do some of these:
Look at /etc/tinydns/log/main/current to see if there's error.
Make sure there's a supervise directory in /etc/tinydns/
Make sure there's No directory under /etc/tinydns/env
remove /service/tinydns link and re-link
remove /etc/tinydns directory and re-create them using tinydns-conf
stop and start the service using "svc" ("svc -d" then "svc_u" or "svc -t" etc.)

Next, just add records to "/etc/tinydns/root/data", and then "make", tinydns should now happily serve any requests from anywhere. If not, use "dig" to debug the problem.