IPOE属于DHCP的认证类型,机顶盒开机将接入用户名及密码加密后封装进 DHCP Discover 包中的Option 60 字段里,发送DHCP请求,DHCP服务器认证成功即可获取IP地址。dhclient工具可以通过命令行直接加参数的形式或者配置文件的形式增加option
虚拟机下面的centos 6.5
获取IP地址方式
(1) 默认所有网口
sudo dhclient -r
或者指定网口:
sudo dhclient eth0 -r
Usage: dhclient [-4|-6] [-SNTP1dvrx] [-nw] [-p ] [-s server]
[-cf config-file] [-lf lease-file][-pf pid-file] [-e VAR=val]
[-I ] [-B]
[-H | -F ] [-timeout ]
[-V ]
[-R ]
[-sf script-file] [interface]
(1) 所有网口
发送字符串:
sudo dhclient -V "name=my centos@pwd=12345678"
(2) 或者指定网口:
sudo dhclient eth0 -V "name=my centos@pwd=12345678"
备注:
默认配置文件路径 /etc/dhcp/dhclient.conf
(1) 当发现不存在 /etc/dhcp/dhclient.conf 文件时,可以查找根目录是否存在文件
find -name "dhc*"
(2) 拷贝配置文件到默认目录
cp /usr/share/doc/dhclient-4.1.1/dhclient.conf.sample /etc/dhcp/dhclient.conf
vi /etc/dhcp/dhclient.conf
(1) 增加 option 60 :
(a) 普通字符串
send vendor-class-identifier "name=my centos@pwd=0123456789";
(b) 16进制值
send vendor-class-identifier 01:02:03:04:05:0A:0B;
(2) 增加 option 61
send dhcp-client-identifier = hardware;
(1) 释放所有网口
sudo dhclient -r
(2) 释放指定网口
sudo eth0 dhclient -r
(1) 所有网口获取
sudo dhclient
(2) 指定网口获取
sudo eth0 dhclient
(1) win7桌面打开wireshark
选择过滤条件:bootp.type
(2) centos 执行命令
释放ip命令
sudo dhclient eth0 -r
获取ip命令
sudo dhclient eth0
(3) 查看wireshark
分析request包
完整配置文件
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 centos@pwd=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;
#}