1 概述
IPOE屬于DHCP的認證類型,機頂盒開機将接入使用者名及密碼加密後封裝進 DHCP Discover 包中的Option 60 字段裡,發送DHCP請求,DHCP伺服器認證成功即可擷取IP位址。dhclient工具可以通過指令行直接加參數的形式或者配置檔案的形式增加option
2 環境
虛拟機下面的centos 6.5
擷取IP位址方式
3 指令行加參數操作
3.1 釋放ip
(1) 預設所有網口
sudo dhclient -r
或者指定網口:
sudo dhclient eth0 -r
3.2 擷取ip
Usage: dhclient [-4|-6] [-SNTP1dvrx] [-nw] [-p <port>] [-s server]
[-cf config-file] [-lf lease-file][-pf pid-file] [-e VAR=val]
[-I <dhcp-client-identifier>] [-B]
[-H <host-name> | -F <fqdn.fqdn>] [-timeout <timeout>]
[-V <vendor-class-identifier>]
[-R <request option list>]
[-sf script-file] [interface]
(1) 所有網口
發送字元串:
sudo dhclient -V "name=my [email protected]=12345678"
(2) 或者指定網口:
sudo dhclient eth0 -V "name=my [email protected]=12345678"
4 通過配置檔案修改
備注:
預設配置檔案路徑 /etc/dhcp/dhclient.conf
4.1 找配置檔案
(1) 當發現不存在 /etc/dhcp/dhclient.conf 檔案時,可以查找根目錄是否存在檔案
find -name "dhc*"
(2) 拷貝配置檔案到預設目錄
cp /usr/share/doc/dhclient-4.1.1/dhclient.conf.sample /etc/dhcp/dhclient.conf
4.2 修改配置檔案
vi /etc/dhcp/dhclient.conf
(1) 增加 option 60 :
(a) 普通字元串
send vendor-class-identifier "name=my [email protected]=0123456789";
(b) 16進制值
send vendor-class-identifier 01:02:03:04:05:0A:0B;
(2) 增加 option 61
send dhcp-client-identifier = hardware;
4.3 釋放ip
(1) 釋放所有網口
sudo dhclient -r
(2) 釋放指定網口
sudo eth0 dhclient -r
4.4 擷取ip
(1) 所有網口擷取
sudo dhclient
(2) 指定網口擷取
sudo eth0 dhclient
5 抓包分析
(1) win7桌面打開wireshark
選擇過濾條件:bootp.type
(2) centos 執行指令
釋放ip指令
sudo dhclient eth0 -r
擷取ip指令
sudo dhclient eth0
(3) 檢視wireshark
分析request包
6 附錄
完整配置檔案
send host-name "andare.fugue.com";
send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
send dhcp-lease-time 3600;
supersede domain-search "fugue.com", "home.vix.com";
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-search, domain-name, domain-name-servers, host-name;
require subnet-mask, domain-name-servers;
timeout 60;
send vendor-class-identifier "name=my [email protected]=0123456789";
send dhcp-client-identifier = hardware;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/etc/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;
#alias {
# interface "ep0";
# fixed-address 192.5.5.213;
# option subnet-mask 255.255.255.255;
#}
#lease {
# interface "ep0";
# fixed-address 192.33.137.200;
# medium "link0 link1";
# option host-name "andare.swiftmedia.com";
# option subnet-mask 255.255.255.0;
# option broadcast-address 192.33.137.255;
# option routers 192.33.137.250;
# option domain-name-servers 127.0.0.1;
# renew 2 2000/1/12 00:00:01;
# rebind 2 2000/1/12 00:00:01;
# expire 2 2000/1/12 00:00:01;
#}