我尝试使用node js在raspberry pi 4上设置固定IP,如果我使用sudo运行以下脚本
var networkconfig = require('network-config');
var my_net_cfg = {
ip: '192.168.1.15',
netmask: '255.255.255.0',
gateway: '192.168.1.1'
}
networkconfig.configure('eth0', my_net_cfg, function (err) {
console.log(err);
});我在控制台上得到'null‘,IP没有改变。
我是否需要在raspbian上禁用DHCP或其他功能??
谢谢!
发布于 2019-10-12 04:30:54
我发现问题了,我在设置新的ip时忘记了强制重启eht0。
正确的my_net_cfg应该是
var my_net_cfg = {
ip: '192.168.1.15',
netmask: '255.255.255.0',
gateway: '192.168.1.1',
restart: true
}也许其他人也犯了同样的错误。
https://stackoverflow.com/questions/58347730
复制相似问题