How can I get ip address with C/glib of my local computer which get from route.
Asked
Active
Viewed 762 times
2 Answers
0
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.

Manuel Salvadores
- 16,287
- 5
- 37
- 56