• 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
How to get the gateway's IP address of a NIC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Subject: How to get the gateway's IP address of a NIC
  • From: "Jerry" <email@hidden>
  • Date: Wed, 19 Mar 2008 11:02:39 -0700

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 
 _______________________________________________
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

  • Prev by Date: Re: IPv6 connection from second computer?
  • Next by Date: Re: How to get the gateway's IP address of a NIC
  • Previous by thread: Re: poll on BPF devices
  • Next by thread: Re: How to get the gateway's IP address of a NIC
  • Index(es):
    • Date
    • Thread