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:
Operator error. I was editing the wrong file.