Date: Tue, 16 Sep 2008 07:01:14 -0400 From: "Chris Inacio" <nacho319@gmail.com> To: freebsd-net@freebsd.org Subject: help with code to determine external IP address on FreeBSD gateway machine Message-ID: <900019150809160401v316682fdt4cf8a95bfcb48dc2@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hello, I'm writing a tiny bit of code to do NAT-PMP and I need code that can determine what the external facing IP address is on a machine with presumably multiple interfaces. I think I have a method in mind which would involve getting the default route, and then figuring out which interface is reachable by that default route. There are always all the other methods of going out to a web site which will reflect my IP address back to me on a web site - and while reliable, that seems sort of hackish. So the thing is, I'm not super familiar with the necessary ioctl calls, or routing socket calls, or...? Can somebody save me a ton of time and just point me in the right direction as to how to get this done? I was looking through the code of src/net/route.c, but decided a lot of context was needed to understand what I was reading. Any help would be very much appreciated. Thanks, Chris
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?900019150809160401v316682fdt4cf8a95bfcb48dc2>