Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

90
Visualizações
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 Respostas
Responde à pergunta

0

Operator error. I was editing the wrong file.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda