鸿蒙的网络管理与linux常用的NetworkManager不同,静态IP配置文件也不一样了,以下方式测试可用。

# 本地创建一个新的配置文件
cat > ethernet_interfaces.json <<EOF
{
  "config_ethernet_interfaces":[
    {
      "iface":"eth0",
      "caps":[
      ],
      "ip":"192.168.0.10",
      "gateway":"192.168.0.1",
      "dns":"",
      "netmask":"255.255.255.0",
      "route":"",
      "routemask":""
    }
  ]
}
EOF

# 修改system分区为可写并上传配置文件
hdc shell "mount -o rw,remount /"
hdc file send ethernet_interfaces.json /system/etc/communication/netmanager_ext/

# 重启生效
hdc shell reboot

# 重启后确认生效
hdc shell "ifconfig eth0"

参考:Openharmony标准系统润和DAYU200设置静态IP

Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐