Android路由表设置(route & DNS)
来源:互联网 发布:软件申请专利流程 编辑:程序博客网 时间:2024/05/16 18:38
route设置
android4.4只使用了一份路由表,使用busybox route就可以完成路由表的设置,从android5.0之后,考虑要对多网络的支持,采用了多路由表,下面的设置方法只适用于android4.4之前的版本,android5.0之后的版本路由表如何设置留到以后再说明。
1、查看路由表 busybox route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.7.1 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 192.168.7.1 0.0.0.0 UG 202 0 0 eth0
192.168.0.0 0.0.0.0 255.255.248.0 U 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.248.0 U 202 0 0 eth0
192.168.7.1 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
2、删除默认路由 busybox route del default
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.7.1 0.0.0.0 UG 202 0 0 eth0
192.168.0.0 0.0.0.0 255.255.248.0 U 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.248.0 U 202 0 0 eth0
192.168.7.1 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
3、添加一条默认路由 busybox route add -net 0.0.0.0 gw 192.168.7.1 netmask 0.0.0.0 dev eth0
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.7.1 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.248.0 U 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.248.0 U 202 0 0 eth0
192.168.7.1 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
4、删除一条主机路由 busybox route del -host 192.168.7.1 dev eth0
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.7.1 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.248.0 U 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.248.0 U 202 0 0 eth0
5、添加一条主机路由 busybox route add -host 192.168.7.1 dev eth0
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.7.1 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.248.0 U 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.248.0 U 202 0 0 eth0
192.168.7.1 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
6、删除一条网络路由 busybox route del -net 192.168.0.0 netmask 255.255.248.0 dev eth
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.7.1 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.248.0 U 202 0 0 eth0
7、添加一条网络路由 busybox route add -net 192.168.0.0 netmask 255.255.248.0 dev eth
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.7.1 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.248.0 U 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.248.0 U 202 0 0 eth0
DNS Server设置
同样以android4.4为例来进行说明,Android系统中,不管是dns server的设置,还是域名解析,都是由netd进程来执行的,netd与dns的相关操作是调用了一个netbsd的库,netd中dns server设置对应于文件ResolverController.cpp,域名解析对应于文件DnsProxyListener.cpp。
原生的android系统只提供了设置系统dns server的接口,而没有提供查看系统dns server的接口,需要自己添加代码来实现。
通过ndc配合netd可以对android dns进行设置和查看。
1、设置dns interface & server
ndc resolver setdefaultif eth0
ndc resolver setifdns eth0 “” 192.168.7.2
2、查看dns interface
ndc resolver getdefaultif
226 0 DNS default interface is eth0
3、查看dns server
ndc resolver getdefaultServer 1
226 0 DNS default server[1] is 192.168.7.2
- Android路由表设置(route & DNS)
- Android网络设置(route & DNS)
- Route (DOS设置路由表)
- route设置路由
- route-map策略路由设置
- ip route默认路由设置
- ip route默认路由设置
- linux 路由表设置 之 route 指令详解
- linux 路由表设置 之 route 指令详解
- linux 路由表设置 之 route 指令详解
- linux 路由表设置 之 route 指令详解
- linux 路由表设置 之 route 指令详解
- linux 路由表设置 之 route 指令详解
- linux 路由表设置 之 route 指令详解
- linux 路由表设置 之 route 指令详解
- linux 路由表设置 之 route 指令详解
- linux 路由表设置 之 route 指令详解
- Android 和 iOS 实现路由(route)系统。
- mysql 存储过程
- eval 的作用
- Android可伸缩布局-FlexboxLayout(支持RecyclerView集成)
- Android面试题-为什么需要token
- 中小站做SEO,就是安全第一,安全第一,安全第一
- Android路由表设置(route & DNS)
- Centos 端口转发
- java用正则方法验证文件名是否合法
- BZOJ3482: [COCI2013]hiperprostor
- 机场A-CDM系统建设发展现状-网络资源整理
- CSU 1892: Nested Dolls(2007 Nordic Collegiate Programming Contest)
- pyqt5用pyinstaller打包
- Innosetup相关操作简介
- 玩过的游戏