Solved

TCP/IP: Determine IP# for PPP interface on WIN32

Posted on 1998-07-29
3
182 Views
Last Modified: 2010-03-05
The following code will provide you with the IP# on the primary Ethernet Card in Win95. However, it won't let you find out your current PPP IP#.

Extra Special points for anyone who can tell me how to find ALL IP#'s on the machine (ex. 2 PPP connects + 2 ethernet cards) - using PERL not winipcfg :-)

Thanks,
Timothy


use Sys::Hostname;
print "start of an IP Poster in PERL\n";
print join '.', unpack 'C4', gethostbyname hostname;
print "\n" . hostname;
0
Comment
Question by:tcolson
3 Comments
 

Expert Comment

by:ijduggan
ID: 1208876
Is it possible for you to just parse the output of the netstat program?

"netstat -n"  returns data on current connections. You could try something like:

my %connections;
open(NETSTAT, "netstat -n |");
while(<NETSTAT>) {


process netstat data


}

Does netstat provide you with enough information to do what you want?

0
 

Author Comment

by:tcolson
ID: 1208877
IJDUGGAN wrote:
>Does netstat provide you with enough information
>to do what you want?
Unfortunately no - Netstat provides you with currently active connections on specific ports. So, for example, right now I'm connected to my ISP...and every 5 minutes my email client polls for mail -> during this time:
C:\WINDOWS>netstat
Active Connections
  Proto  Local Address          Foreign Address        State
  TCP    homebrew:1045          popserver.somewhere.com:pop3  TIME_WAIT

However, after this connection has closed:
C:\WINDOWS>netstat
Active Connections
  Proto  Local Address          Foreign Address        State

-> No data. But I am still connected to my ISP...so there must be another way to find the IP#.

Perhaps the answer lies in finding out where WINIPCFG gets its information from??? This stuff must be in the registry somewhere, eh?

Thanks,
TLC

0
 
LVL 5

Accepted Solution

by:
b2pi earned 100 total points
ID: 1208878
It's doable... but somewhat difficult.  You'll rely heavily on the registry module, and I'll assume you know how to use that.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Adapters
has subkeys that are a list of all the adapters. Those that are active will have NameServer and NameServerBackup values (but those will be blank)

On my machine, I've got
HKLM\CurrentControlSet\Services\NetBT\Adapters\El90x1
and
HKLM\CurrentControlSet\Services\NetBT\Adapters\NdisWan6

Then, go to
HKLM\CurrentControlSet\Services\X\Parameters\Tcpip
(Where X is one of the listed subkeys above, for instance El90x1, above)
and look at the value IPAddress for for the IPAddress.

So, that's of moderate difficulty?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now