• 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
Getting own IP address
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting own IP address


  • Subject: Getting own IP address
  • From: "Matt Slot" <email@hidden>
  • Date: Mon, 28 Apr 2003 18:42:22 -0400

Yes, I know... lots of interfaces, everything is dynamic, yadda yadda.

I'm working on some code to cope with NAT limitations, and I need to
detect when the client is behind the same NAT as the computer it wants
to join (ignoring the double-NAT case).

I've written an abstraction function to return the list of currently
available interfaces/IP addresses, but I'm getting inconsistent and
strange results from the various APIs.

My home machine is configured as follows:

Default: Ethernet / DHCP - gets IP 24.95.76.171
Airport / Manual - set to 10.0.1.2

Airport Internet Sharing is on, one host connects using 10.0.1.3.


When I use ioctl(OSIOCGIFCONF) to talk to the BSD layer, I get the
following list on my home machine.

10.0.2.1
10.0.1.2
24.95.76.171
127.0.0.1

I don't know where the first address comes from, but its not listed in
my Network preferences. I also can't figure out why the IP address for
the default interface is not at the top of the list I get.


Under OpenTransport/CFM, I get the following list:

24.95.76.171
127.0.0.1

Upon further research, it looks like I'm only querying 1 interface, and
its secondary addresses. I'll add the code to loop over all interfaces
shortly.


So, I have 2 real questions:

Where is 10.0.2.1 coming from? I assume it's related to the
Internet Sharing feature, but how?

How do I get the IPs in the order the user sees them within
the Network preferences dialog?

Thanks,

Matt
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Getting own IP address
      • From: Quinn <email@hidden>
    • Re: Getting own IP address
      • From: Justin Walker <email@hidden>
References: 
 >Rendezvous Name (From: Mike Cohen <email@hidden>)

  • Prev by Date: Forcing PAP on OSX
  • Next by Date: Re: Getting own IP address
  • Previous by thread: Re: Rendezvous Name
  • Next by thread: Re: Getting own IP address
  • Index(es):
    • Date
    • Thread