更改ip后无法DHCP临时解决方案

原由

实验室使用sigma工具测试11ac ap,需要192.165.100网段的DUT,而DUT默认的是192.168.43的网段。故需要更改一版临时版本以供测试。

修改

frameworks/base/services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java

diff --git a/services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java b/services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java
index 2619338..60059fa 100644
--- a/services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java
+++ b/services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java
@@ -70,7 +70,7 @@ public class TetherInterfaceStateMachine extends StateMachine {

private static final String USB_NEAR_IFACE_ADDR = "192.168.42.129";
private static final int USB_PREFIX_LENGTH = 24;
- private static final String WIFI_HOST_IFACE_ADDR = "192.168.43.1";
+ private static final String WIFI_HOST_IFACE_ADDR = "192.165.100.1";
private static final int WIFI_HOST_IFACE_PREFIX_LENGTH = 24;
private static final String WIGIG_HOST_IFACE_ADDR = "192.168.50.1";
private static final int WIGIG_HOST_IFACE_PREFIX_LENGTH = 24;

测试结果

结果当DUT设置为Softap模式时,STA去连接时无法获取IP地址,而当设置为静态ip时,就可以正常连接,所以怀疑是DHCP的问题。

排查

log 分析

09-04 02:45:04.480 I/dnsmasq ( 4078): started, version 2.51 cachesize 150
09-04 02:45:04.481 I/dnsmasq ( 4078): compile time options: IPv6 GNU-getopt no-I18N DHCP no-scripts
09-04 02:45:04.481 W/dnsmasq ( 4078): warning: no upstream servers configured
09-04 02:45:04.481 I/dnsmasq ( 4078): DHCP, IP range 192.168.51.2 -- 192.168.51.254, lease time 1h
09-04 02:45:04.481 I/dnsmasq ( 4078): DHCP, IP range 192.168.50.2 -- 192.168.50.254, lease time 1h
09-04 02:45:04.481 I/dnsmasq ( 4078): DHCP, IP range 192.168.49.2 -- 192.168.49.254, lease time 1h
09-04 02:45:04.481 I/dnsmasq ( 4078): DHCP, IP range 192.168.48.2 -- 192.168.48.254, lease time 1h
09-04 02:45:04.481 I/dnsmasq ( 4078): DHCP, IP range 192.168.47.2 -- 192.168.47.254, lease time 1h
09-04 02:45:04.481 I/dnsmasq ( 4078): DHCP, IP range 192.168.46.2 -- 192.168.46.254, lease time 1h
09-04 02:45:04.481 I/dnsmasq ( 4078): DHCP, IP range 192.168.45.2 -- 192.168.45.254, lease time 1h
09-04 02:45:04.481 I/dnsmasq ( 4078): DHCP, IP range 192.168.44.2 -- 192.168.44.254, lease time 1h
09-04 02:45:04.481 I/dnsmasq ( 4078): DHCP, IP range 192.168.43.2 -- 192.168.43.254, lease time 1h
09-04 02:45:04.481 I/dnsmasq ( 4078): DHCP, IP range 192.168.42.2 -- 192.168.42.254, lease time 1h
09-04 02:45:04.483 I/dnsmasq ( 4078): read /etc/hosts - 2 addresses
09-04 02:45:04.486 I/dnsmasq ( 4078): Closing wildcard listener family=2
09-04 02:45:04.486 I/dnsmasq ( 4078): Closing wildcard listener family=10

DHCP池没有192.165.100范围的ip

进程

ps -ef | grep dhcp

willow:/ # ps -ef |grep dhcp
ps -ef |grep dhcp
dns_tether    3802   544 1 02:48:42 ?     00:00:00 dnsmasq --keep-in-foreground --no-resolv --dhcp-host=wpad,set:Blacklist --dhcp-host=isatap,set:Blacklist --dhcp-host=autodiscovery,set:Blacklist --dhcp-host=autoreconf,set:Blacklist --dhcp-ignore-names=tag:Blacklist --no-poll --dhcp-authoritative --dhcp-option-force=43,ANDROID_METERED --pid-file --listen-mark 0xf0063 --user dns_tether --dhcp-range=192.168.42.2,192.168.42.254,1h --dhcp-range=192.168.43.2,192.168.43.254,1h --dhcp-range=192.168.44.2,192.168.44.254,1h --dhcp-range=192.168.45.2,192.168.45.254,1h --dhcp-range=192.168.46.2,192.168.46.254,1h --dhcp-range=192.168.47.2,192.168.47.254,1h --dhcp-range=192.168.48.2,192.168.48.254,1h --dhcp-range=192.168.49.2,192.168.49.254,1h --dhcp-range=192.168.50.2,192.168.50.254,1h --dhcp-range=192.168.51.2,192.168.51.254,1h

所以确定dnsmasq dhcp-range没有192.165.100的网段。

解决方案

在shell里输入以下的指令

dnsmasq --keep-in-foreground --no-resolv --dhcp-host=wpad,set:Blacklist --dhcp-host=isatap,set:Blacklist --dhcp-host=autodiscovery,set:Blacklist --dhcp-host=autoreconf,set:Blacklist --dhcp-ignore-names=tag:Blacklist --no-poll --dhcp-authoritative --dhcp-option-force=43,ANDROID_METERED --pid-file --listen-mark 0xf0063 --user dns_tether --dhcp-range=192.165.100.2,192.165.100.254,1h

后续追踪

因为项目较为紧急,所以以此方法进行测试。后续有空再进行代码的挖掘,看一下dnsmasq在哪里进行设置了dhcp-range的参数。

剑气纵横三万里

“为什么要努力?” “想去的地方很远,想要的东西很贵,喜欢的人很优秀,父母的白发,朋友的约定,周围人的嘲笑,以及,天生傲骨。”

留下你的评论

*评论支持代码高亮<pre class="prettyprint linenums">代码</pre>

相关推荐

暂无内容!