Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Hostid changing with network
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
prestige787
n00b
n00b


Joined: 18 Sep 2021
Posts: 37

PostPosted: Fri Oct 28, 2022 2:53 pm    Post subject: Hostid changing with network Reply with quote

I'm having a problem where when I use my laptop on a different newtork, the hostid changes. More specifically, when I connect to a wpa2 enterprise network, the hostid becomes 00000000 (found with "hostid" command). On my home network the hostid is very different (still 8 characters though). As far as I know hostid should change only if the hardware changes, not the network you connect to. This is a problem for me as some software I need checks the hostid to validate the license. Is there any way that I can prevent the hostid from changing? I believe I followed the handbook exactly for network setup (dhcp).
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21624

PostPosted: Fri Oct 28, 2022 3:56 pm    Post subject: Reply with quote

What led you to think that the hostid is hardware related? As I read the documentation in man hostid, it has a decent chance of being the IPv4 address of your current hostname, if that is resolvable. That can easily change as you roam networks, so any license locks keyed to it are just defective. They should not be relying on that identifier for anything. Fortunately, according to man gethostid (referenced from man hostid), glibc can get an administrator-chosen hostid from etc, so you should be able to set the hostid to whatever value your broken licensing scheme wants to see.
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Fri Oct 28, 2022 5:09 pm    Post subject: Reply with quote

You could fake the hostid. Create a program '/opt/fake_hostid/bin/hostid':
Code:
#! /bin/bash
echo "1bac013d"

Start the program that calls 'hostid' to check the license with:
Code:
PATH="/opt/fake_hostid/bin:$PATH" yourprogram
Back to top
View user's profile Send private message
no101
n00b
n00b


Joined: 10 Oct 2022
Posts: 11
Location: Piney Woods

PostPosted: Fri Oct 28, 2022 7:02 pm    Post subject: Reply with quote

if /etc/hostid exists, hostid(1) and gethostid(3) will read from that file instead. sethostid(3) will write to that file.

This is a trivial program to write the existing result of gethostid() into /etc/hostid. Run it on a working machine and then when you switch the network, hostid should still return the old id.
Code:

#include <stdio.h>
#include <unistd.h>

int
main()
{
   if (sethostid(gethostid())) {
      perror("sethostid");
   }
}

Save that as save_hostid.c and compile it with
Code:
gcc -o save_hostid save_hostid.c

Only root can execute the sethostid() command so it has to be run as root. You only need to run it once to generate the file, then switch networks and things should just work. To undo the forgery, just remove /etc/hostid.

Note: you should never just blindly run code off the internet so you can check what that code does with
Code:

man 3 sethostid
man 3 perror
Back to top
View user's profile Send private message
prestige787
n00b
n00b


Joined: 18 Sep 2021
Posts: 37

PostPosted: Thu Sep 21, 2023 2:50 pm    Post subject: Reply with quote

Ok it's been a while but I still have not fixed this issue. I believe the root cause is related to this:

https://support.spirent.com/SpirentCSC/SC_KnowledgeView?Id=SOL11499

I've tried a bunch of solutions I found online but none fix the problem.

The ifconfig command has the loop back first, and the actual card second. Is there any way to change this?
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1659

PostPosted: Thu Sep 21, 2023 3:03 pm    Post subject: Reply with quote

https://support.spirent.com/SpirentCSC/SC_KnowledgeView?Id=SOL11499:
Quote:
FLEXnet license manager only understand network interfaces starting with ethX and with network interface names like emX, pXpX, virbrX will return a null MAC address.

This means only ethernet is supported and wireless is not mentioned as available (can be a dumb program). As well as the net.ifnames=0 kernel command-line option needs to be included.
prestige787 wrote:
The ifconfig command has the loop back first, and the actual card second. Is there any way to change this?

This is nothing that is relevant as you can't change it.

If the hostid is changing after connecting to wireless, then, before it is connected, if hostid command gives a valid answer, write it to the file /etc/hostid and it will always be read from there.
Back to top
View user's profile Send private message
prestige787
n00b
n00b


Joined: 18 Sep 2021
Posts: 37

PostPosted: Thu Sep 21, 2023 4:47 pm    Post subject: Reply with quote

I am actually on wifi both times, not connecting to ethernet at all on this particular machine. I have already used a fix provided in this thread to get the hostid command to return a non zero value, however even with net.ifnames=0 set,
Code:
./lmutil lmhostid
returns all zeroes (this is the binary tool the program uses to get the flexnet hostid) on the enterprise network, but on my home networks it returns a non zero value, so it must rely on something other than hostid.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21624

PostPosted: Thu Sep 28, 2023 11:18 pm    Post subject: Reply with quote

For future readers, note that prestige787 opened an additional thread on this topic as Maple17. Given how this thread has gone to date, I am not inclined quite yet to merge the two threads, though I could be convinced to do so. For now, I am settling for posting cross-links in each thread so readers can find both of them.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum