Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Keep IP if DHCP server is offline

Solved!
Go to solution

We have a customer who wants to be able to manage the IPs of all his devices with DHCP, but the devices are expected to keep their IP forever after the DHCP server has been taken offline. Is this a behaviour we can support on a NI controller?

 

If it is not a configurable behaviour one alternative could be to have the controlelr self-configure to the last known IP if no such is aquired...but the Apply Network Settings VI does not seem to work if run on the controller itself. Is this correct?

0 Kudos
Message 1 of 3
(5,127 Views)

Hi Mads,

 

NI devices don't have a way to do this, primarily because it would violate the DHCP protocol.  If the devices kept addresses after the lease expired, then when the DHCP server came back online, it could potentially give an address that is in use to another device.

 

I would suggest, if possible, that you change the lease time on your DHCP server.  If you set the lease time to 1 year (the max if I remember correctly), then as long the DHCP server comes on every now and then, you will never lose your lease.

 

-Jeff

 

0 Kudos
Message 2 of 3
(5,090 Views)
Solution
Accepted by topic author Mads

Together with NI in Norway (thanks) I found a solution that allows us to implement the requested behaviour.

 

The main problem for us once we needed to override the default DHCP behaviour was the fact that the RT Apply Target Network Settings.vi does not work if it is set to target the same controller as it is running on. So how could we swap between DHCP and fixed? Well, as it turns out the network settings are also stored in the ni-rt.ini file. So here's what we do: When the controller starts we check if it is running in DHCP-mode. If not, we change this in the ni-rt.ini file and reboot - to see if the DHCP server is operational. If the controller is running in DHCP we check if the IP address is valid (i.e. outside the link local range). If it is not we read the last known IP address and write those as fixed in the ni-rt.ini file, and reboot.

 

An example of the INI-file sections:

 

For DHCP the section of the ni-rt.ini will look like this:

 

[TCP_Stack_Config]

DNS_Address=USE_DHCP

Gateway=USE_DHCP

IP_Address=USE_DHCP

Subnet_Mask=USE_DHCP

 

For a Static IP:

 

[TCP_Stack_Config]

DNS_Address=0.0.0.0

Gateway=10.0.18.1

IP_Address=10.0.18.13

Subnet_Mask=255.255.255.128

 

It would be nicer if the RT Apply Target Network Settings.vi would work for self-reconfiguration, but this saved the day for us at least in this case.

 

0 Kudos
Message 3 of 3
(4,959 Views)