【问题标题】:How can I set ip address of raspberry-pi4 in nodejs如何在nodejs中设置raspberry-pi4的IP地址
【发布时间】:2019-10-12 04:30:54
【问题描述】:

我尝试使用 node js 在树莓派 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 或其他什么吗??

谢谢!

【问题讨论】:

    标签: node.js raspberry-pi4


    【解决方案1】:

    发现问题,设置新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
    }
    

    也许其他人也会犯同样的错误。

    【讨论】:

      猜你喜欢
      • 2023-03-03
      • 2019-10-16
      • 1970-01-01
      • 1970-01-01
      • 2011-10-02
      • 1970-01-01
      • 2011-05-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多