Entries Tagged as ''

Nslookup vs. Dig

Sadly, I heard nslookup will be gone with the wind. But luckily, we have dig to get more detailed information about domain name. The following are comparison of two commands for www.google.com

[root@hengdu ~]# dig www.google.com

; <<>> DiG 9.5.0b1 <<>> www.google.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37711
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 7, ADDITIONAL: 7

;; QUESTION SECTION:
;www.google.com. IN A

;; ANSWER SECTION:
www.google.com. 105861 IN CNAME www.l.google.com.
www.l.google.com. 300 IN A 66.249.91.99
www.l.google.com. 300 IN A 66.249.91.103
www.l.google.com. 300 IN A 66.249.91.104
www.l.google.com. 300 IN A 66.249.91.147

;; AUTHORITY SECTION:
l.google.com. 24160 IN NS e.l.google.com.
l.google.com. 24160 IN NS f.l.google.com.
l.google.com. 24160 IN NS g.l.google.com.
l.google.com. 24160 IN NS a.l.google.com.
l.google.com. 24160 IN NS b.l.google.com.
l.google.com. 24160 IN NS c.l.google.com.
l.google.com. 24160 IN NS d.l.google.com.

;; ADDITIONAL SECTION:
a.l.google.com. 24373 IN A 209.85.139.9
b.l.google.com. 24255 IN A 64.233.179.9
c.l.google.com. 24160 IN A 64.233.161.9
d.l.google.com. 24373 IN A 66.249.93.9
e.l.google.com. 24311 IN A 209.85.137.9
f.l.google.com. 38846 IN A 72.14.235.9
g.l.google.com. 24553 IN A 64.233.167.9

;; Query time: 13 msec
;; SERVER: 65.39.139.53#53(65.39.139.53)
;; WHEN: Tue Feb 19 10:40:52 2008
;; MSG SIZE rcvd: 340

[root@hengdu ~]# nslookup www.google.com
Server: 65.39.139.53
Address: 65.39.139.53#53

Non-authoritative answer:
www.google.com canonical name = www.l.google.com.
Name: www.l.google.com
Address: 66.249.91.147
Name: www.l.google.com
Address: 66.249.91.99
Name: www.l.google.com
Address: 66.249.91.103
Name: www.l.google.com
Address: 66.249.91.104

How to get percentage of package loss

Due to testing on the network, the package lost rate is needed. The following bash script shows how to get percentage of package loss. I split IP address to four segments since it will be easy to manipulate for loop.

PINGTMP=/tmp/ping.tmp

IP_1=`echo $IPADDRESS | awk -F”.” ‘{print $1}’`
IP_2=`echo $IPADDRESS | awk -F”.” ‘{print $2}’`
IP_3=`echo $IPADDRESS | awk -F”.” ‘{print $3}’`
IP_4=`echo $IPADDRESS | awk -F”.” ‘{print $4}’`
ping -t 5 -c 2 $IP_1.$IP_2.$IP_3.$IP_4 > $PINGTMP
pack_loss=`awk ‘/statistics/{getline;print $6}’ $PINGTMP`
echo $pack_loss