2012年10月26日金曜日

Solaris10でのDHCPデバッグ

DHCPプロトコルは以下のとおり。矢印の左側がDHCPクライアント、右側がDHCPサーバを指す。

<IPアドレス未取得の場合>
 →Message type = DHCPDISCOVER
 ←Message type = DHCPOFFER
 →Message type = DHCPREQUEST
 ←Message type = DHCPACK

<IPアドレス取得済みマシンがリブートした時>
 →Message type = DHCPREQUEST
 ←Message type = DHCPACK

Solaris10にてDHCPのデバッグとして、2通りのやり方がある。
 1.DHCPサーバ側でパケットをキャプチャする
 2.DHCPサーバをデバッグモードで動かす

●DHCPサーバ側でパケットをキャプチャする

以下、snoop実行時にDHCPクライアントが再起動した時の例。

bash-3.00# snoop -d e1000g0 -o /tmp/snoop.out udp port 67 or udp port 68
DHCPクライアントが再起動後、DHCPサーバ側にて[Ctrl]+[C]で閉じる。

bash-3.00# snoop -i /tmp/snoop.out -x0 -v
ETHER:  ----- Ether Header -----
ETHER:
ETHER:  Packet 1 arrived at 5:04:33.73759
ETHER:  Packet size = 342 bytes
ETHER:  Destination = ff:ff:ff:ff:ff:ff, (broadcast)
ETHER:  Source      = 0:c:29:67:84:89,
ETHER:  Ethertype = 0800 (IP)
ETHER:
IP:   ----- IP Header -----
IP:
IP:   Version = 4
IP:   Header length = 20 bytes
IP:   Type of service = 0x00
IP:         xxx. .... = 0 (precedence)
IP:         ...0 .... = normal delay
IP:         .... 0... = normal throughput
IP:         .... .0.. = normal reliability
IP:         .... ..0. = not ECN capable transport
IP:         .... ...0 = no ECN congestion experienced
IP:   Total length = 328 bytes
IP:   Identification = 0
IP:   Flags = 0x4
IP:         .1.. .... = do not fragment
IP:         ..0. .... = last fragment
IP:   Fragment offset = 0 bytes
IP:   Time to live = 255 seconds/hops
IP:   Protocol = 17 (UDP)
IP:   Header checksum = 7aa5
IP:   Source address = 0.0.0.0, OLD-BROADCAST
IP:   Destination address = 255.255.255.255, BROADCAST
IP:   No options
IP:
UDP:  ----- UDP Header -----
UDP:
UDP:  Source port = 68
UDP:  Destination port = 67 (BOOTPS)
UDP:  Length = 308
UDP:  Checksum = 8943
UDP:
DHCP: ----- Dynamic Host Configuration Protocol -----
DHCP:
DHCP: Hardware address type (htype) =  1 (Ethernet (10Mb))
DHCP: Hardware address length (hlen) = 6 octets
DHCP: Relay agent hops = 0
DHCP: Transaction ID = 0x5b32ba17
DHCP: Time since boot = 0 seconds
DHCP: Flags = 0x0000
DHCP: Client address (ciaddr) = 0.0.0.0
DHCP: Your client address (yiaddr) = 0.0.0.0
DHCP: Next server address (siaddr) = 0.0.0.0
DHCP: Relay agent address (giaddr) = 0.0.0.0
DHCP: Client hardware address (chaddr) = 00:0C:29:67:84:89
DHCP:
DHCP: ----- (Options) field options -----
DHCP:
DHCP: Message type = DHCPREQUEST
DHCP: Requested IP Address = 192.168.10.3
DHCP: IP Address Lease Time = -1 seconds
DHCP: Maximum DHCP Message Size = 1472 bytes
DHCP: Client Class Identifier = "SUNW.i86pc"
DHCP: Requested Options:
DHCP:    1 (Subnet Mask)
DHCP:    3 (Router)
DHCP:    6 (DNS Servers)
DHCP:   12 (Client Hostname)
DHCP:   15 (DNS Domain Name)
DHCP:   28 (Broadcast Address)
DHCP:   43 (Vendor Specific Options)
DHCP: Client Hostname = sol10-dhcp-client

           0: ffff ffff ffff 000c 2967 8489 0800 4500    ........)g....E.
          16: 0148 0000 4000 ff11 7aa5 0000 0000 ffff    .H..@...z.......
          32: ffff 0044 0043 0134 8943 0101 0600 5b32    ...D.C.4.C....[2
          48: ba17 0000 0000 0000 0000 0000 0000 0000    ................
          64: 0000 0000 0000 000c 2967 8489 0000 0000    ........)g......
          80: 0000 0000 0000 0000 0000 0000 0000 0000    ................
          96: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         112: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         128: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         144: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         160: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         176: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         192: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         208: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         224: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         240: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         256: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         272: 0000 0000 0000 6382 5363 3501 0332 04c0    ......c.Sc5..2..
         288: a80a 0333 04ff ffff ff39 0205 c03c 0a53    ...3.....9...<.S
         304: 554e 572e 6938 3670 6337 0701 0306 0c0f    UNW.i86pc7......
         320: 1c2b 0c11 736f 6c31 302d 6468 6370 2d63    .+..sol10-dhcp-c
         336: 6c69 656e 74ff                             lient.
ETHER:  ----- Ether Header -----
ETHER:
ETHER:  Packet 2 arrived at 5:04:33.75531
ETHER:  Packet size = 342 bytes
ETHER:  Destination = 0:c:29:67:84:89,
ETHER:  Source      = 0:c:29:52:33:cc,
ETHER:  Ethertype = 0800 (IP)
ETHER:
IP:   ----- IP Header -----
IP:
IP:   Version = 4
IP:   Header length = 20 bytes
IP:   Type of service = 0x00
IP:         xxx. .... = 0 (precedence)
IP:         ...0 .... = normal delay
IP:         .... 0... = normal throughput
IP:         .... .0.. = normal reliability
IP:         .... ..0. = not ECN capable transport
IP:         .... ...0 = no ECN congestion experienced
IP:   Total length = 328 bytes
IP:   Identification = 21163
IP:   Flags = 0x4
IP:         .1.. .... = do not fragment
IP:         ..0. .... = last fragment
IP:   Fragment offset = 0 bytes
IP:   Time to live = 255 seconds/hops
IP:   Protocol = 17 (UDP)
IP:   Header checksum = 0000
IP:   Source address = 192.168.10.4, sol10-dhcp-server
IP:   Destination address = 192.168.10.3, 192.168.10.3
IP:   No options
IP:
UDP:  ----- UDP Header -----
UDP:
UDP:  Source port = 67
UDP:  Destination port = 68 (BOOTPC)
UDP:  Length = 308
UDP:  Checksum = 969D
UDP:
DHCP: ----- Dynamic Host Configuration Protocol -----
DHCP:
DHCP: Hardware address type (htype) =  1 (Ethernet (10Mb))
DHCP: Hardware address length (hlen) = 6 octets
DHCP: Relay agent hops = 0
DHCP: Transaction ID = 0x5b32ba17
DHCP: Time since boot = 0 seconds
DHCP: Flags = 0x0000
DHCP: Client address (ciaddr) = 0.0.0.0
DHCP: Your client address (yiaddr) = 192.168.10.3
DHCP: Next server address (siaddr) = 0.0.0.0
DHCP: Relay agent address (giaddr) = 0.0.0.0
DHCP: Client hardware address (chaddr) = 00:0C:29:67:84:89
DHCP:
DHCP: ----- (Options) field options -----
DHCP:
DHCP: Message type = DHCPACK
DHCP: DHCP Server Identifier = 192.168.10.4
DHCP: UTC Time Offset = 32400 seconds
DHCP: RFC868 Time Servers at = 192.168.10.4
DHCP: IP Address Lease Time = 86400 seconds
DHCP: Broadcast Address = 192.168.10.255
DHCP: Perform Router Discovery Flag flag = 0x1
DHCP: Subnet Mask = 255.255.255.0

           0: 000c 2967 8489 000c 2952 33cc 0800 4500    ..)g....)R3...E.
          16: 0148 52ab 4000 ff11 0000 c0a8 0a04 c0a8    .HR.@...........
          32: 0a03 0043 0044 0134 969d 0201 0600 5b32    ...C.D.4......[2
          48: ba17 0000 0000 0000 0000 c0a8 0a03 0000    ................
          64: 0000 0000 0000 000c 2967 8489 0000 0000    ........)g......
          80: 0000 0000 0000 0000 0000 0000 0000 0000    ................
          96: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         112: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         128: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         144: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         160: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         176: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         192: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         208: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         224: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         240: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         256: 0000 0000 0000 0000 0000 0000 0000 0000    ................
         272: 0000 0000 0000 6382 5363 3501 0536 04c0    ......c.Sc5..6..
         288: a80a 0402 0400 007e 9004 04c0 a80a 0433    .......~.......3
         304: 0400 0151 801c 04c0 a80a ff1f 0101 0104    ...Q............
         320: ffff ff00 ff00 0000 0000 0000 0000 0000    ................
         336: 0000 0000 0000                             ......

●DHCPサーバをデバッグモードで動かす

以下、デバッグモードで実行時にDHCPクライアントが再起動した時の例。

bash-3.00# svcadm disable -t svc:/network/dhcp-server
bash-3.00# /usr/lib/inet/in.dhcpd -d -v
50899ead:  Daemon Version: 3.5
50899ead:  Maximum relay hops: 4
50899ead:  Run mode is: DHCP Server Mode.
50899ead:  Datastore resource: SUNWfiles
50899ead:  Location: /var/dhcp
50899ead:  DHCP offer TTL: 10
50899ead:  ICMP validation timeout: 1000 milliseconds, Attempts: 1.
50899ead:  Name service update enabled, timeout: 15 seconds
50899ead:  Maximum concurrent clients: 1024
50899ead:  Maximum threads: 256
50899ead:  Read 3 entries from DHCP macro database on Fri Oct 26 05:18:53 2012
50899ead:  Monitor (0003/e1000g0) started...
50899ead:  Thread Id: 0003 - Monitoring Interface: e1000g0 *****
50899ead:  MTU: 1500    Type: SOCKET
50899ead:  Broadcast: 192.168.10.255
50899ead:  Monitor (0004/e1000g1) started...
50899ead:  Thread Id: 0004 - Monitoring Interface: e1000g1 *****
50899ead:  MTU: 1500    Type: SOCKET
50899ead:  Broadcast: 10.20.30.255
50899ead:  Netmask: 255.255.255.0
50899ead:  Netmask: 255.255.255.0
50899ead:  Address: 192.168.10.4
50899ead:  Address: 10.20.30.4
★ここで待ち
50899f86:  Datagram received on network device: e1000g1(limited broadcast)
50899f86:  Datagram received on network device: e1000g0(limited broadcast)
50899f86:  e1000g1(limited broadcast): There is no 10.20.30.0 dhcp-network table for DHCP client's network.
50899f86:  name_avail:  unqualified name
qualified with local domain: sol10-dhcp-client.private.net.
50899f86:  name_avail(T):  gethostbyname_r failed
50899f86:  name service update on behalf of client with ID 000C29678489 failed because requested name was not fully-qualified and no DNS domain name was specified for this client in the dhcptab
50899f86:  do_nsupdate:  dns_puthostent returned -1
50899f86:  Client: 01000C29678489 maps to IP: 192.168.10.3
50899f86:  Unicasting datagram to 192.168.10.3 address.
50899f86:  Adding ARP entry: 192.168.10.3 == 000C29678489
★[Ctrl]+[C]押下
^C5089a050:  Signal: INT received...Exiting
5089a050:  Closing interface: e1000g0
5089a050:  Monitor (0003/e1000g0): exiting.
5089a050:  Interface statistics for: e1000g0 **************
5089a050:  Pending DHCP offers: 0
5089a050:  Total Packets Transmitted: 1
5089a050:  Total Packets Received: 1
5089a050:  Total Packet Duplicates: 0
5089a050:  Total Packets Dropped: 0
5089a050:  Total Packets Processed: 1
5089a050:  Total Protocol Errors: 0
5089a050:  Closing interface: e1000g1
5089a050:  Monitor (0004/e1000g1): exiting.
5089a050:  Interface statistics for: e1000g1 **************
5089a050:  Pending DHCP offers: 0
5089a050:  Total Packets Transmitted: 0
5089a050:  Total Packets Received: 1
5089a050:  Total Packet Duplicates: 0
5089a050:  Total Packets Dropped: 0
5089a050:  Total Packets Processed: 0
5089a050:  Total Protocol Errors: 0
5089a050:  Daemon terminated.