2015年8月13日

dhcp誰發的

在研習時突然有個想法:在ubuntu下如果用dhcp取得IP,如果DHCP很多台,又或是有某一台AP設錯接錯,你如何知道你的DHCP是誰給的。查了一下網路終於知道方法了,記錄一下
指令是
先執行
sudo dhclient
看log檔
sudo cat /var/lib/dhcp/dhclient.leases  |grep dhcp
  option dhcp-lease-time 28800;
  option dhcp-message-type 5;
  option dhcp-server-identifier 192.168.2.1;


用arp指令可以知道這台主機的mac 
arp 192.168.2.1
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.2.1              ether   ac:22:0b:53:36:d4   C                     wlan0

route可以知道路由走法
route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.231.97.254   0.0.0.0         UG    0      0        0 eth0
10.231.97.0     *               255.255.255.0   U     1      0

ifconfig 可以知道網卡設定
ifconfig
eth0      Link encap:Ethernet  HWaddr 74:27:ea:d6:ee:18 
          inet addr:10.231.97.138  Bcast:10.231.97.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:102971 errors:0 dropped:0 overruns:0 frame:0
          TX packets:82446 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:100619102 (100.6 MB)  TX bytes:12285296 (12.2 MB)
          Interrupt:18

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:6700 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6700 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:775749 (775.7 KB)  TX bytes:775749 (775.7 KB)

沒有留言: