[twsocket] Need Advice / Help on how to find the correct IP's

Ralf Buml Sledge-Hammer@t-online.de
Tue, 13 Jun 2000 13:08:40 +0200


Hi Wilfried!

Ok, i see... I'll do an IP Adress check as you told me... Seems to be the
easiest and best method to get the IP's right...

I wasn't sure if there is no other way.

The WinSocket FAQ tells something about an Delphi Routine to figure it out.
But, i don't have a glue what this routine exactly does...
It's told that this gets only the Internet-IP. This funktion is from RAS.PAS
which can be downloaded from the ICS-Homepage

Maybe someone can help so i can port it to C++

-----------------
function RasGetIPAddress: string;
var
    RASConns   : TRasConn;
    dwSize     : DWORD;
    dwCount    : DWORD;
    RASpppIP   : TRASPPPIP;
begin
    Result          := '';
    RASConns.dwSize := SizeOf(TRASConn);
    RASpppIP.dwSize := SizeOf(RASpppIP);
    dwSize          := SizeOf(RASConns);
    if RASEnumConnectionsA(@RASConns, @dwSize, @dwCount) = 0 then begin
        if dwCount > 0 then begin
            dwSize := SizeOf(RASpppIP);
            RASpppIP.dwSize := SizeOf(RASpppIP);
            if RASGetProjectionInfoA(RASConns.hRasConn,
                                     RASP_PppIp,
                                     @RasPPPIP,
                                     @dwSize) = 0 then
                Result := StrPas(RASpppIP.szIPAddress);
       end;
    end;
end;
----------------------


>You are never 100 procent sure.
>
>- A LAN can have a public address (it should not).
>
>- If the internet connection is tru a router witch does NAT then you have
>internet connection to the LAN card with a private ip address.
>
>rgds, Wilfried
>
>> -----Original Message-----
>> From: twsocket-admin@elists.org [mailto:twsocket-admin@elists.org]On
>> Behalf Of Ralf Buml
>> Sent: dinsdag 13 juni 2000 5:36
>> To: twsocket@elists.org
>> Subject: RE: [twsocket] Need Advice / Help on how to find the correct
>> IP's
>>
>>
>>
>> Hi Wilfried!
>>
>> >Please include the original question in future. As I remember
>> you wanted to
>> >know if you had a connection on witch interface it was or witch
>> one was the
>> >internet one.
>> I'm sorry, i didn't know that :( Shouldn't happen again!
>>
>> My question was: "How can i determine which of the IP-Adresses is assigned
>> to the internet and which one is the IP of the network-card"
>> I want to know that before the connection is made.
>> Just like the Windows-Tool NETIPCFG
>>
>> The problem is: My program gets the IPs already but sometimes
>> does the mistake to sitch these adresses so they are in the wrong place.
>>
>> Example:
>> Private Network-IP: 192.168.0.1
>> Internet-IP:  62.244.34.132
>>
>> So if the user has 1 Network card my program tells him:
>> Private Network-IP: 192.168.0.1
>> Internet-IP: None
>>
>> if the user has 1 Network card and is has an Internet-IP at the
>> same time my program tells him:
>> Private Network-IP: 192.168.0.1
>> Internet-IP: 62.244.34.132
>>
>> And now the problem again:
>> if the user has only an Internet-IP and no Network card installed
>> my program tells him:
>> Private Network-IP: 62.244.34.132
>> Internet-IP: None
>>
>> And thats the problem. I want to be 100% sure which one is
>> assigned to which interface.
>>
>> Hope you have an idea...
>>
>> Greets
>> 	Ralf
>>
>> >Wel if you can connect with addr '0.0.0.0' you have the ip of the server.
>> >You can call LocalIpList to get list of all interface cards.
>> Next step is to
>> >set LocalAddr property to the first one and try to connect
>> again. If it dont
>> >work, then it's the wrong one, you can try the next, etc, and if
>> connect is
>> >ok then you have the interface witch is connected to internet.
>> >
>> >If I'm completely wrong here pleas ask the original question again.
>> >
>> >rgds, Wilfried
>> >
>> >> -----Original Message-----
>> >> From: twsocket-admin@elists.org [mailto:twsocket-admin@elists.org]On
>> >> Behalf Of Ralf Buml
>> >> Sent: maandag 12 juni 2000 19:43
>> >> To: twsocket@elists.org
>> >> Subject: RE: [twsocket] Need Advice / Help on how to find the correct
>> >> IP's
>> >>
>> >>
>> >>
>> >> Hi Wilfried!
>> >>
>> >> Thanx for your answer! :)
>> >>
>> >> It's ok... I knew the thing with the IP-Adresses already.
>> >> But as your last paragraph says some users don't know
>> >> which IP-Adresses are valid. (I was such a user some years
>> >> ago, wondering why my Network never worked on TCP/IP :)))
>> >>
>> >> Is there no other way than checking these adresses?
>> >> This way is much too unsecure for my needs and will be the
>> >> last escape if any other way is possible...
>> >>
>> >> Greets
>> >> Ralf
>> >>
>> >> >Normally (if lan ip properly configured), the lan ip address
>> should be a
>> >> >private netwerk, and the internet ip address is a public one.
>> >> Difference is
>> >> >a private network is normally not routed. Private are:
>> >> >
>> >> >class A (for very large networks):
>> >> >10.0.0.0 / 8
>> >> >
>> >> >class B (for large networks):
>> >> >172.16.0.0 / 12
>> >> >
>> >> >class C (small networks):
>> >> >192.168.0.0 / 16
>> >> >
>> >> >Note if someone does not untherstand: the /nn is the number of bits
>> >> >belonging to the network. eg: the class B machines: is from
>> 172.16.0.1 to
>> >> >172.31.255.254
>> >> >
>> >> >However, I have seen many LAN's with public addresses also
>> because many
>> >> >people (including the network administrators) does not know it.
>
>
>_______________________________________________
>TWSocket mailing list [http://elists.org/mailman/listinfo/twsocket]
>Visit our website at http://www.rtfm.be/fpiette/indexuk.htm 



So long        Ralf

- need you, dream you, find you, fuck you, use you, scar you, break you -
-        lose me, hate me, smash me, erase me (N.I.N. - ERASER)         -
-         Homepage:  http://www.t-online.de/home/sledge-hammer          -