OpenHarmony以太网卡静态IP配置方法
鸿蒙的网络管理与linux常用的NetworkManager不同,静态IP配置文件也不一样了,以下方式测试可用。 # 本地创建一个新的配置文件 cat > ethernet_interfaces.json <
·
鸿蒙的网络管理与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":"0.0.0.0",
"routemask":"0.0.0.0"
}
]
}
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"
============时间线 20241107=============
根据下面的回复,修改路由配置
============时间线 20250624=============
如果有多块网卡配置了IP地址,每块网卡的route/routemask有区别。如果配置不正确可能导致无法正常连接外网(且现象和两个网口UP的先后顺序有关)。
如果网卡的网关是默认网关,那么配置route和routemask为0.0.0.0,否则配置route和routemask为""。
更多推荐
所有评论(0)