Solved

Get IP Address (Batch File)

Posted on 2004-09-06
7
5,947 Views
Last Modified: 2012-06-27
I want to get the external Ip address of a computer. The computer has two IP addresses, one on the PPP adapter and one on the local network connection.

I want the one that can be seen from the internet.

It'll be passed into a batch file so i would consider a great answer to be if someone could parse the ipconfig details:


Windows 2000 IP Configuration

Ethernet adapter Local Area Connection:

      Connection-specific DNS Suffix  . :
      IP Address. . . . . . . . . . . . : 192.168.0.1
      Subnet Mask . . . . . . . . . . . : 255.255.255.0
      Default Gateway . . . . . . . . . :

PPP adapter BT Yahoo! Broadband:

      Connection-specific DNS Suffix  . :
      IP Address. . . . . . . . . . . . : 81.154.249.XX
      Subnet Mask . . . . . . . . . . . : 255.255.255.255
      Default Gateway . . . . . . . . . : 81.154.249.XX

(I've convered the last two octets for security reasons but they would be there!)

Can anyone help me parse this file or get me the IP address another way?

Thanks

 Phillip Taylor
0
Comment
Question by:Philluminati
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 57

Accepted Solution

by:
Pete Long earned 250 total points
ID: 11992032
Hi Philluminati,
see http:Q_20743821.html#9399250

Cheers!
0
 

Author Comment

by:Philluminati
ID: 11992079
Nope....doesn't work.

Doesn't even seem like a similar question if you ask me. Can someone parse the IP Address in the bottom half of the print out (above) and give me the code to do it?

Thanks

  Phill
0
 

Expert Comment

by:darkpred-learning
ID: 12086600
why dont u try this....

ipconfig/all > C:/path/ip.log

and then add a string with the value "mailto:" and your email...
0
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 
LVL 1

Expert Comment

by:shanekelly_7
ID: 12239282
Okay! I have made in the past a batch file that does exactly that!

------Start of Batch Script!-----
@echo off
:: edit the two lines Below for your subject line and your email address
set to=someone@domain.com
set sub=Subject_line

for /f "tokens=2* delims=:" %%a in ('ipconfig ^| find "IP Address"') do set ip=%%a
set sub=%sub: =+%
start mailto:%to%?subject=%sub%^&body=The+IP+is;+%ip%
exit
-----End of Batch Script!-----

Good Luck!
- Shane
0
 
LVL 1

Expert Comment

by:shanekelly_7
ID: 12239353
Sorry Mate my Code need a little Debuging.
Use this:
------Start of Batch Script!-----
@echo off
:: edit the two lines Below for your subject line and your email address
set to=someone@domain.com
set sub=Subject_line

for /f "tokens=2* delims=:" %%a in ('ipconfig ^| find "IP Address"') do set ip=%%a
set sub=%sub: =+%
set ip=%ip: =+%
start mailto:%to%?subject=%sub%^&body=The+IP+is;+%ip%
exit
-----End of Batch Script!-----

Good Luck! (again)
- Shane
0
 

Author Comment

by:Philluminati
ID: 12240448
This posting ended ages ago. I've solved the problem and awarded the points to the name specified.
0
 
LVL 1

Expert Comment

by:shanekelly_7
ID: 12241516
Just adding extra help
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

752 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