Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

91
Vistas
Node JS Change IP of host not reflected in REST API GET response

I have a server that was built using OpenAPI and node JS, that serves get/put requests for network configuration. The following is the underlying server code for the GET/PUT of the IP address.

var execSync = require('child_process').execSync;
var os = require('os');
var ip = require('ip');

function readIp()
{
    var command = "hostname -I";
    var ip_addr = execSync(command).toString().trim();
    console.log("Ip address: " + ip_addr);
    return ip;
}

function setIp(ipAddr)
{
    var command = 'ifconfig eth0 ' + ipAddr + ' netmask 255.255.255.0';
    execSync(command);
}

When I do a PUT to change the IP address, it does change the IP address of the host, this is verified because I run ifconfig on the host directly after executing the PUT.

The issue is when I use a GET to read the IP address afterwords, the change in IP address is not reflected. For instance, lets say the IP address of host is 193.168.60.115. I do a PUT and change the IP to 193.168.60.110. Then I do a GET and the response still returns 193.168.60.115, the old IP Address. When I run ifconfig the IP address is the correctly changed immediately after the PUT. I am not sure why GET is not returning the updated IP address.

What I have tried:

  • I tried using a few different methods for reading the IP address. I used the os module and the child_process module and both have the same results.
  • I tried disabling caching on firefox but still got same result.
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Operator error. I was editing the wrong file.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda