![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-07 21:31 |
48,041 topics / 350,128 posts / today 3 new / 48,252 members |
| DOS批处理 & 脚本技术(批处理室) » Urgent!!! Batch processing to view local IP and external network IP |
| Printable Version 1,883 / 7 |
| Floor1 sea1112 | Posted 2008-03-18 14:23 |
| 初级用户 Posts 119 Credits 131 From gz | |
|
Urgent!!! Batch processing to view local IP and external network IP
Question: Can batch processing be used to check the external network IP? (The local IP is: 192.168.1.2~254, which is the internal network here) |
|
| Floor2 bat-zw | Posted 2008-03-18 14:35 |
| 金牌会员 Posts 1,276 Credits 3,105 | |
|
Yes, but I don't know which external network you want to view. Is it the external network IP of the LAN server host?
|
|
| Floor3 dikex | Posted 2008-03-18 14:43 |
| 高级用户 Posts 366 Credits 788 | |
|
External network IP
Use wget.exe (http://www.yx127.com/tools/wget_1.82.rar) |
|
| Floor4 sea1112 | Posted 2008-03-18 14:47 |
| 初级用户 Posts 119 Credits 131 From gz | |
|
Still need to download files? I made one.
@echo off echo Set objXML = WScript.GetObject("http://www.apnic.net/") >>apnic.vbs echo While objXML.readyState = "loading">>apnic.vbs echo WScript.Sleep 100>>apnic.vbs echo Wend>>apnic.vbs echo Set coll = objXML.getElementsByTagName("td")>>apnic.vbs echo WScript.Echo coll(0).innertext>>apnic.vbs echo Set objXML = Nothing>>apnic.vbs for /f "delims=: tokens=2" %%i in ('cscript //nologo apnic.vbs') do set "wip=%%i" echo 本机外网IP是 %wip%>>ip.txt del apnic.vbs /q |
|
| Floor5 dikex | Posted 2008-03-18 14:57 |
| 高级用户 Posts 366 Credits 788 | |
|
One of the differences between VBS and batch processing:
Batch processing does not have a built-in download command; In the case of pure batch processing, it is to use wget. P.S. The above has a grammar error (It seems there was an issue with line breaks during copy - paste), modified as follows: [ Last edited by dikex on 2008 - 3 - 18 at 03:01 PM ] |
|
| Floor6 bat-zw | Posted 2008-03-18 14:58 |
| 金牌会员 Posts 1,276 Credits 3,105 | |
|
I think it's better to use tracert:
tracert www.baidu.com pause In the subsequent list of IPs, the first non-local area network IP from top to bottom is the external network IP of the local area network. As for whether it's necessary to list it separately, it's probably not necessary. |
|
| Floor7 dikex | Posted 2008-03-18 15:01 |
| 高级用户 Posts 366 Credits 788 | |
|
I think tracert is sometimes strange:
Now my IP is 59.41.32.* But the result of tracert www.baidu.com is: Tracing route to www.a.shifen.com over a maximum of 30 hops: 1 43 ms 42 ms 43 ms 220.181.37.55 Trace complete. |
|
| Floor8 bat-zw | Posted 2008-03-18 16:17 |
| 金牌会员 Posts 1,276 Credits 3,105 | |
|
```
@echo off for /f "delims=: tokens=2" %%i in ('ipconfig/all ^| find "DNS"') do set dns=%%i for /f "skip=6 tokens=8" %%i in ('tracert %dns%') do set ip=%%i echo %ip% 注:在我这里(xp+sp2环境)skip=6,不知道你那里是要设为5还是6? 也可以这样: @echo off for /f "skip=6 tokens=8" %%i in ('tracert %dns%') do ( for /f "delims=: tokens=2" %%i in ('ipconfig/all ^| find "DNS"') do ( set dns=%%i ) set ip=%%i ) echo %ip% [ Last edited by zw19750516 on 2008-3-18 at 05:33 PM ] ``` |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |