此问题堪称从业多年来困扰最大,方向全无的终极问题之一
问题来源
如上截图来源华为hilink平台适配调试文档。
新做的hilink linux网关,需要通过DHCP dicover包,上报option 60信息,信息内容就是一段字符串,例如huawei:hilink:gateway
DHCP包发送
-
我遇到这个问题,以为是在用户层代码,通过DHCP接口发送discover包,其中增加option60段,内容填充huawei:hilink:gateway即可,这个思想是错误的,方向性错误。应该是修改系统dhcp设置即可。
-
大部分人,包括我自己只知道dhcp是获取ip的,但是对dhcp的整个过程不是太了解,所以改变字段更是无从下手。
-
这个DHCP包是通过linux系统设置,具体步骤我是这样尝试的,但是失败了
-
buildroot中增加dhcp client设置
-
升级网关系统,在etc/dhcp/下面有个dhclient.conf文件
-
在dhclient.conf文件中增加send vendor-class-identifier "huawei:hilink:gateway";(其中vendor-class-identifier就是60(3C)的字段标识。)
-
如下方法只能在dhcp的request包中增加了vendor-class-identifier(60)字段,但是值不是我设置的,而是系统默认的,所以修改此文件并未得到执行。
-
我再ubuntu电脑按照此方法修改,dhcp的request的包中是"huawei:hilink:gateway"
-
-
为什么要在discover增加字段,我在request中修改呢,因为找不到discover的位置,而且不会改这个conf文件
-
附上conf文件内容
[root@sraum-gateway:/etc/dhcp]# ls
dhclient.conf
[root@sraum-gateway:/etc/dhcp]# cat dhclient.conf
# Configuration file for /sbin/dhclient, which is included in Debian's
# dhcp3-client package.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
# man page for more information about the syntax of this file
# and a more comprehensive list of the parameters understood by
# dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
# not leave anything out (like the domain name, for example), then
# few changes must be made to this file, if any.
#
#send host-name "andare.fugue.com";
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name,
netbios-name-servers, netbios-scope;
#require subnet-mask, domain-name-servers;
#timeout 60;
send vendor-class-identifier "huawei:hilink:gateway";
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/etc/dhcp3/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;
#alias {
# interface "eth0";
# fixed-address 192.5.5.213;
# option subnet-mask 255.255.255.255;
#}
#lease {
# interface "eth0";
# 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;
#}
问题分析
-
修改文件系统,这个方向是不是也是错的?
-
修改dhcp request,以为dicorver会自动加上option60 ,这个方向是不是也是错的?基本可以确定是错的。
-
问题最终一定会解决,但是不知道以什么方式解决,加油吧!!!!!!!!!!!!!!!
附录:DHCP流程(来源网络)
DHCP请求IP地址的过程如下:
1)主机发送DHCPDISCOVER广播包在网络上寻找DHCP服务器;
2)DHCP服务器向主机发送DHCPOFFER单播数据包,包含IP地址、MAC地址、域名信息以及地址租期;
3)主机发送DHCPREQUEST广播包,正式向服务器请求分配已提供的IP地址;
4)DHCP服务器向主机发送DHCPACK单播包,确认主机的请求