Skip to content
Advertisement

Get IP address of an interface on Linux

How can I get the IPv4 address of an interface on Linux from C code?

For example, I’d like to get the IP address (if any) assigned to eth0.

Advertisement

Answer

Try this:

JavaScript

The code sample is taken from here.

Advertisement