0

I try to set fixed IP on a raspberry pi 4 with node js and if I run the following script with 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);
});

I get 'null' on console and the IP doesn't change.

Do I need to disable DHCP or something else on raspbian ??

Thanks!

Eugen T
  • 13
  • 1
  • 4

1 Answers1

0

I found the problem, I forgot to force restart eht0 when I set the new ip.

The correct my_net_cfg should be

var my_net_cfg = {
    ip: '192.168.1.15',
    netmask: '255.255.255.0',
    gateway: '192.168.1.1',
    restart: true
}

Maybe someone else makes the same mistake.

Eugen T
  • 13
  • 1
  • 4