OpenHarmony开发者论坛
标题:
openharmony配置网络
[打印本页]
作者:
Hazel
时间:
7 天前
标题:
OpenHarmony配置网络
[md]方法一:通过命令行配置(临时)
```gradle
ifconfig eth0 192.168.10.100 netmask 255.255.255.0
route add default gw 192.168.100.1
```
方法二:写配置文件
```
对/foundation/communication/netmanager_ext/services/ethernetmanager/config/ethernet_interfaces.json文件进行IP配置,重新编译烧录后即可。
#cat /system/etc/communication/netmanager_ext/ethernet_interfaces.json
{
"config_ethernet_interfaces":[
{
"iface":"eth0",
"caps":[
],
"ip":"192.168.10.120",
"gateway":"192.168.10.255",
"dns":"",
"netmask":"255.255.255.0",
"route":"",
"routemask":""
},
{
"iface":"",
"caps":[
],
"ip":"",
"gateway":"",
"dns":"",
"netmask":"",
"route":"",
"routemask":""
}
]
}
```
查看网络信息:
```
查看ip:
ifconfig -a
查看路由表:
cat /proc/net/fib_trie
```
或者通过自己移植busybox,使用ip工具族查看或修改网络
[/md]
欢迎光临 OpenHarmony开发者论坛 (https://forums.openharmony.cn/)
Powered by Discuz! X3.5