Linux Client not reporting correct IP address

Where does the Ignition client in Linux get it’s IP address info?
I thought it was the hosts file but changes to that do not seem to make a difference.

I am using Linux Mint 18 with Kernel 4.15.2
Ignition 7.9.5

I have a project that ties together IP address to a workcenter. Recent network changes are making hard coded IP addresses on the client a thing of the past, so I am writing a project to insert the IP address along with a dropdown selection, into a table for the assignemnt.

My project shows IP address from:
[System]Client/Network/IPAddress as aaa.bbb.ccc.165
ifconfig shows my IP address as aaa.bbb.cccc.169

My hosts file shows:
aaa.bbb.ccc.169 VPNLT398

This does not occur with the same project on a Windows client.

It reports the value of InetAddress.getLocalHost().getHostAddress(): https://docs.oracle.com/javase/8/docs/api/java/net/InetAddress.html#getLocalHost--

Interesting then that it is reporting the wrong address...

I have implemented an admittedly hackish workaround via client startup script:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('a.b.c.d', 1))
local_ip_address = s.getsockname()[0]
system.tag.write('[Client]IPAddress',local_ip_address)

In the presence of multiple network interfaces somebody will always think the returned address is the “wrong” one.

With a little work you can write a script that enumerates the network interfaces, chooses the correct one for your deployment, and gets the address from that interface.

1 Like

What I am telling you is that the IP address being returned by Ignition is wrong… I found the Windows PC that is the actual IP address: aaa.bbb.ccc.165.

My PC has an Ethernet IP address of aaa.bbb.ccc.169. So what I am telling you is that I find it strange that Ignition (via Java) is returning an IP address that is not in any way associated with my PC.

Do you have multiple network adapters in the system? Can you past the results of ipconfig?

Yes, here is the ifconfig (Linux Client) It's a laptop. One Ethernet on the laptop (not used) one on the docking station (used) and 2 VMWare adapters (vmware not running). Just trying to unravel why a different IP address is being reported by Ignition (and not one of the ones in my system)

enp0s31f6 Link encap:Ethernet HWaddr 54:e1:ad:f2:05:0c
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:16 Memory:ec200000-ec220000

enx0050b6900891 Link encap:Ethernet HWaddr 00:50:b6:90:08:91
inet addr:10.254.0.169 Bcast:10.254.0.175 Mask:255.255.255.240
inet6 addr: fe80::117d:71d8:2f88:8121/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:121276 errors:0 dropped:0 overruns:0 frame:0
TX packets:104767 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:85696274 (85.6 MB) TX bytes:23367421 (23.3 MB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:83025 errors:0 dropped:0 overruns:0 frame:0
TX packets:83025 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:43186189 (43.1 MB) TX bytes:43186189 (43.1 MB)

vmnet1 Link encap:Ethernet HWaddr 00:50:56:c0:00:01
inet addr:192.168.151.1 Bcast:192.168.151.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fec0:1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:207 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

vmnet8 Link encap:Ethernet HWaddr 00:50:56:c0:00:08
inet addr:172.16.179.1 Bcast:172.16.179.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fec0:8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:206 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

It’s not supposed to be cached anywhere, but… if you restart does it show up correctly?

edit: restart client, restart OS

No luck. Shutdown completely, Rebooted, Reloaded Designer, still showing wrong IP under:
[System]Client/Network/IPAddress

Deleted .ignition, shutdown, restarted. Same issue

Deleted java cash, shutdown, restarted. Same issue.

This is not the end of the world, but certainly explains some issues I have had with a couple of terminals behaving in an abnormal manner.

I have existing Linux terminals (Circa 2014 running Java 1.6, Ignition 7.8.4, not sure Kernel) that are not having this issue…

Do you think trying an “old” version of Java may yield different results? Unfortunately it’s been 3.5 years since I have done any development work as it relates to client IP, but back then I know that the host file was the end all be all when it came to reporting IP address in Ignition.

So I pulled out an older laptop:

Java - 1.8.0.111-b14
Kernel - 4.4.0-21
Linux Mint 18 Sarah
IP address: 10.254.0.167

on this laptop hosts file had:

127.0.0.1 localhost
127.0.1.1 tbackus-ThinkPad-X1-Carbon-2nd

The first run,
[System]Client/Network/IPAddress showed an IP of 127.0.1.1

Change second line of /etc/hosts to:
10.254.0.167 tbackus-ThinkPad-X1-Carbon-2nd

Then Run designer and get:
[System]Client/Network/IPAddress showed an IP of 10.254.0.167

======
Back to my laptop

Java - 1.8.0._161-b12
Kernel - 4.15.2-041502
Linux Mint 8 Sylvia
IP address: 10.254.0.169

verified /etc/hosts:
10.254.0.169 VPNLT198
192.168.151.1 VPNLT198
172.16.179.1 VPNLT198

Run Designer:

[System]Client/Network/IPAddress = 10.254.0.165

So the differences:

Dotted update on Linux Mint 18:
18 to 18.3

Different Java Version:
1.8.0.111-b14 to 1.8.0._161-b12

Different Kernel:
4.4.0-21 to 4.15.2-041502

NEW INFO:

This Python script ALSO returns WRONG IP (found by Google search):

import socket
socket.gethostbyname(socket.gethostname())

result = 10.254.0.165

I am at a loss....

Flush DNS and ARP caches? I don’t know either :confused:

Last time I messed with this stuff, I learned that the order in /etc/hosts matters. First, the machine’s dns name is determined, then that name is looked up, and the first entry that satisfies it is used. The lookup generally occurs with the short host name, not the FQDN. The line in hosts that has the IP address you wish reported as the primary address must be ahead of any other line that could match, including the localhost lines.

Now I feel really dumb… Typo in hosts file.

$ cat /etc/hostname
VPNLT398
$ cat /etc/hosts
10.254.0.169 VPNLT198

How or why that would result in an IP being reported as something different I do not know…