• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: How to get the gateway's IP address of a NIC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: How to get the gateway's IP address of a NIC


  • Subject: RE: How to get the gateway's IP address of a NIC
  • From: Jerry Chang <email@hidden>
  • Date: Fri, 21 Mar 2008 01:52:48 -0400
  • Importance: Normal

Thanks for the information. I will give it a try. :)

Jerry




> From: email@hidden
> To: email@hidden; email@hidden
> Subject: Re: How to get the gateway's IP address of a NIC
> Date: Wed, 19 Mar 2008 16:45:19 -0400
>
> On Wed, Mar 19, 2008, Jerry <email@hidden> wrote:
>
> >Hi there,
> >
> >I was using the system configuration to retrieve the gateway's IP address,
> >and it works fine until I use manually assigned static IP address.
> >
> >The key in system configuration is "State:/Network/Service/(a service ID for
> >en0, en1, ...)/IPv4/Router". So I got the gateway IP from using
> >"kSCPropNetIPv4Addresses" key programmatically.
> >
> >When using the static IP(no DHCP), I found out that the Router field is
> >disappeared. However, the "NetworkSignature" key contains a string that has
> >the router's IP address. This key's value is in this format:
> >"IPv4.Router=xxx.xxx.xxx.xxx;RouterHardwareAddress=xx:xx:xx:xx:xx"
> >
> >I could get the gateway IP from parsing the string but I do not think this
> >is a good solution because they key name may change or the format of the
> >value may change as well in the future.
> >
> >Is there another way or better way to retrieve the gateway's IP address?
> >Such as an network API or BSD function.
> >
> >Thanks,
> >Jerry
>
> Hi Jerry,
>
> the typical ways are to fetch the routing table either with sysctl or by
> using a PF_ROUTE raw socket. Stevens' book "Unix Network Programming"
> would be a good place to start.
>
> Cheers.....Peter
>
> p.s. remember that an interface does not have to have a gateway. Most do
> but it's not required
>


Windows Live Hotmail is giving away Zunes. Enter for your chance to win.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: How to get the gateway's IP address of a NIC (From: "Peter Lovell" <email@hidden>)

  • Prev by Date: Re: How to get the gateway's IP address of a NIC
  • Next by Date: 10.5.2 and wireless network joining behavior
  • Previous by thread: Re: How to get the gateway's IP address of a NIC
  • Next by thread: 10.5.2 and wireless network joining behavior
  • Index(es):
    • Date
    • Thread