查看: 104|回复: 0

OpenHarmony配置网络

[复制链接]

3

主题

3

回帖

20

积分

新手上路

积分
20
发表于 2025-3-30 17:40:47 | 显示全部楼层 |阅读模式
方法一:通过命令行配置(临时)
  1. ifconfig eth0 192.168.10.100 netmask 255.255.255.0
  2. route add default gw 192.168.100.1
复制代码
方法二:写配置文件
  1. 对/foundation/communication/netmanager_ext/services/ethernetmanager/config/ethernet_interfaces.json文件进行IP配置,重新编译烧录后即可。
  2. #cat /system/etc/communication/netmanager_ext/ethernet_interfaces.json
  3. {
  4.   "config_ethernet_interfaces":[
  5.     {
  6.       "iface":"eth0",
  7.       "caps":[
  8.       ],
  9.       "ip":"192.168.10.120",
  10.       "gateway":"192.168.10.255",
  11.       "dns":"",
  12.       "netmask":"255.255.255.0",
  13.       "route":"",
  14.       "routemask":""
  15.     },
  16.     {
  17.       "iface":"",
  18.       "caps":[
  19.       ],
  20.       "ip":"",
  21.       "gateway":"",
  22.       "dns":"",
  23.       "netmask":"",
  24.       "route":"",
  25.       "routemask":""
  26.     }
  27.   ]
  28. }
复制代码
查看网络信息:
  1. 查看ip:
  2. ifconfig -a
  3. 查看路由表:
  4. cat /proc/net/fib_trie   
复制代码
或者通过自己移植busybox,使用ip工具族查看或修改网络
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表