本帖最后由 lygzhan 于 2022-1-18 16:21 编辑
我看到有一个朋友说的对了。ac+ap的dhcp是需要配置 opention也就是需要用到扩展协议的。
配置网络支持dhcp option 43和option 60携带的capwapc的master和slave server的信息。客户端解释这个option43 Openwrt配置
服务器端/etc/config/dhcp通过vendorclass来定义一个分类器,将携带’oakridge’vendor class的客户端分到独立的’oakridge’ networkid下。 然后为这些客户强制发送option 43的信息,不论客户端有没有请求. - config vendorclass 'oakridge'
- option vendorclass 'oakridge'
- option networkid 'oakridge'
- option force '1'
- list dhcp_option'43,1,4,192.168.100.117,1,4,192.168.100.20,2,12,ac1.test.com'
转换为/var/etc/dnsmasq.conf如下 - dhcp-vendorclass=oakridge,oakridge
- dhcp-option-force=oakridge,43,1,4,192.168.100.117,1,4,192.168.100.20,2,12,ac1.test.com
客户端配置/etc/config/network指定vendorid为oakridge,并请求option 43 - config interface 'lan1'
- option ifname 'eth0.1'
- option type 'bridge'
- option proto 'dhcp'
- option vendorid 'oakridge'
- option reqopts '43'
修改客户端udhcpc代码,将option 43携带信息转换为脚本/lib/netifd/dhcp.sh的环境变量- ---a/networking/udhcp/common.c
- +++b/networking/udhcp/common.c
- @@ -41,6 +41,7 @@ const struct dhcp_optflagdhcp_optflags[
- { OPTION_STRING_HOST , 0x28 },
- { OPTION_IP | OPTION_LIST , 0x29 },
- { OPTION_IP | OPTION_LIST | OPTION_REQ, 0x2a },
- + {OPTION_STRING | OPTION_REQ, 0x2b },
- { OPTION_IP | OPTION_LIST , 0x2c },
- { OPTION_U32 , 0x33 },
- { OPTION_IP , 0x36 },
- @@ -108,6 +109,7 @@ const char dhcp_option_strings[]ALIGN1
- "nisdomain" "\0"
- "ni违禁软件v" "\0"
- "ntpsrv" "\0"
- +"acaddr" "\0"
- "wins" "\0"
- "lease" "\0"
- "serverid" "\0"
修改客户端udhcpc调用的脚本/lib/netifd/dhcp.sh- # add option43 server list into capwapc configfile
- [ -n "$acaddr" ] && {
- acaddrs=`echo $acaddr | awk -F',' '{for(i=1;i <= NF; i++){if(i%3==0)print $i}}'`;
- uci delete capwapc.server.option43_server
- for addr in $acaddrs
- do
- uci add_listcapwapc.server.option43_server=$addr;
- done
- uci commit capwapc;
- }
- llwang@VM1~ $ dnsmasq --help dhcp
- Known DHCP options:
- 1 netmask
- 2 time-offset
- 3 router
- 6 dns-server
- 7 log-server
- 9 lpr-server
- 13 boot-file-size
- 15 domain-name
- 16 swap-server
- 17 root-path
- 18 extension-path
- 19 ip-forward-enable
- 20 non-local-source-routing
- 21 policy-filter
- 22 max-datagram-reassembly
- 23 default-ttl
- 26 mtu
- 27 all-subnets-local
- 31 router-discovery
- 32 router-solicitation
- 33 static-route
- 34 trailer-encapsulation
- 35 arp-timeout
- 36 ethernet-encap
- 37 tcp-ttl
- 38 tcp-keepalive
- 40 nis-domain
- 41 nis-server
- 42 ntp-server
- 44 netbios-ns
- 45 netbios-dd
- 46 netbios-nodetype
- 47 netbios-scope
- 48 x-windows-fs
- 49 x-windows-dm
- 58 T1
- 59 T2
- 60 vendor-class
- 64 nis+-domain
- 65 nis+-server
- 66 tftp-server
- 67 bootfile-name
- 68 mobile-ip-home
- 69 smtp-server
- 70 pop3-server
- 71 nntp-server
- 74 irc-server
- 77 user-class
- 93 client-arch
- 94 client-interface-id
- 97 client-machine-id
- 119 domain-search
- 120 sip-server
- 121 classless-static-route
- 125 vendor-id-encap
- 255 server-ip-address
DHCP Client的选项
UDHCPC选项说明- udhcpc -p /var/run/udhcpc-br-lan1.pid -s /lib/netifd/dhcp.script -f-t 0 -i br-lan1 -V oakridge -C -O 43
- BusyBox v1.19.4 (2017-01-17 16:59:34 CST) multi-callbinary.
-
- Usage: udhcpc [-fbnqoCRB] [-i IFACE] [-r IP] [-s PROG] [-pPIDFILE]
- [-H HOSTNAME] [-V VENDOR] [-x OPT:VAL]... [-OOPT]...
-
- -i,--interface IFACE Interface to use (defaulteth0)
- -p,--pidfile FILE Create pidfile
- -s,--script PROG Run PROG at DHCP events (default/usr/share/udhcpc/default.script)
- -B,--broadcast Request broadcast replies
- -t,--retries N Send up to N discover packets
- -T,--timeout N Pause between packets (default 3seconds)
- -A,--tryagain N Wait N seconds after failure (default20)
- -f,--foreground Run in foreground
- -b,--background Background if lease is notobtained
- -n,--now Exit if lease is not obtained
- -q,--quit Exit after obtaining lease
- -R,--release Release IP on exit
- -S,--syslog Log to syslog too
- -O,--request-option OPT Request option OPT from server(cumulative)
- -o,--no-default-options Don't request any options (unless -O isgiven)
- -r,--request IP Request this IP address
- -x OPT:VAL Include option OPT in sent packets(cumulative)
- Examples of string, numeric, and hex byte opts:
- -x hostname:bbox - option 12
- -x lease:3600 - option 51 (lease time)
- -x 0x3d:0100BEEFC0FFEE - option 61 (client id)
- -F,--fqdn NAME Ask server to update DNS mapping forNAME
- -H,-h,--hostname NAME Send NAME as client hostname (defaultnone)
- -V,--vendorclass VENDOR Vendor identifier (default 'udhcpVERSION')
- -C,--clientid-none Don't send MAC as clientidentifier
- Signals:
- USR1 Renew current lease
- USR2 Release current lease
这就是配置。最简单的办法就是 用ac做dhcp服务器。这样你就不用配置了。直接把主路由的dhcp关掉。不知道是会不会配置ac的全局dhcp。用端口dhcp是不行的。
|