How to get local ip address on Linux?
Posted: Sat Oct 21, 2023 1:36 am
Hi,
The following code works differently on Linux (Ubuntu) than it does on OS3 (under WinUAE) and Windows 10 (under Wine).
I thought GetLocalIP() would give me the ip address of the server but it prints 0.0.0.0. Am I misusing it somehow?
The second DebugPrint() gives me 192.168.0.12 on OS3 and Windows which is correct but on Linux it gives me 127.0.1.1 which is technically correct but I need to get to the 192.168.0.12 on Linux also. Is there a way to get that? Thanks.
NathanH
The following code works differently on Linux (Ubuntu) than it does on OS3 (under WinUAE) and Windows 10 (under Wine).
Code: Select all
CreateServer(1, 49152)
DebugPrint(GetLocalIP(1, #NETWORKSERVER))
DebugPrint(ToIP(GetHostName()))
The second DebugPrint() gives me 192.168.0.12 on OS3 and Windows which is correct but on Linux it gives me 127.0.1.1 which is technically correct but I need to get to the 192.168.0.12 on Linux also. Is there a way to get that? Thanks.
NathanH