Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

89
Views
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 answers
Answer question

0

Operator error. I was editing the wrong file.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!