开发者

glib get ip address from route

How can I get ip add开发者_Python百科ress with C/glib of my local computer which get from route.


I'm not really sure what you mean with "get from route".

But if want to get the IP you're using outside your LAN then just wrap up this command into a system call.

curl -s http://myip.dk/ | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'

It always works.


You can use libgtop, in particular you can use a mix of netlist and netload. With netlist you can get the network interface list, and with netload you can get the information for each interface (or the interface you are interested in).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜