windows下,用命令行进行系统的TCP/IP设置

原创 2007年09月23日 13:08:00
 

HTML Tags and JavaScript tutorial



windows下,用命令行进行系统的TCP/IP设置





In order to configure TCP/IP settings such as the IP address, Subnet Mask, Default Gateway, DNS and WINS addresses and many other options you can use Netsh.exe.
Netsh.exe is a command-line scripting utility that allows you to, either locally or remotely, display or modify the network configuration of a computer that is currently running. Netsh.exe also provides a scripting feature that allows you to run a group of commands in batch mode against a specified computer. Netsh.exe can also save a configuration script in a text file for archival purposes or to help you configure other servers.
Netsh.exe is available on Windows 2000, Windows XP and Windows Server 2003.
You can use the Netsh.exe tool to perform the following tasks:

Configure interfaces


Configure routing protocols


Configure filters


Configure routes


Configure remote access behavior for Windows-based remote access routers that are running the Routing and Remote Access Server (RRAS) Service


Display the configuration of a currently running router on any computer


Use the scripting feature to run a collection of commands in batch mode against a specified router.

What can we do with Netsh.exe?
With Netsh.exe you can easily
view your TCP/IP settings
. Type the following command in a Command Prompt window (CMD.EXE):
netsh interface ip show config
With Netsh.exe, you can easily
configure your computer's IP address and other TCP/IP related settings
. For example:
The following command configures the interface named Local Area Connection with the static IP address 192.168.0.100, the subnet mask of 255.255.255.0, and a default gateway of 192.168.0.1:
netsh interface ip set address name="Local Area Connection" static 192.168.0.100 255.255.255.0 192.168.0.1 1
(The above line is one long line, copy paste it as one line)
Netsh.exe can be also useful in certain scenarios such as when you have a portable computer that needs to be relocated between 2 or more
office
locations, while still maintaining a specific and static IP address configuration. With Netsh.exe, you can easily save and restore the appropriate network configuration.
First, connect your portable computer to location #1, and then manually configure the required settings (such as the IP address, Subnet Mask, Default Gateway, DNS and WINS addresses).
Now, you need to
export your current IP settings
to a text file. Use the following command:
netsh -c interface dump > c:/location1.txt
When you reach location #2, do the same thing, only keep the new settings to a different file:
netsh -c interface dump > c:/location2.txt
You can go on with any other location you may need, but we'll keep it simple and only use 2 examples.
Now, whenever you need to quickly
import your IP settings
and change them between location #1 and location #2, just enter the following command in a Command Prompt window (CMD.EXE):
netsh -f c:/location1.txt
or
netsh -f c:/location2.txt
and so on.
You can also use the global EXEC switch instead of -F:
netsh exec c:/location2.txt
Netsh.exe can also be used to configure your NIC to
automatically obtain an IP address from a DHCP server
:
netsh interface ip set address "Local Area Connection" dhcp
Would you like to
configure DNS and WINS addresses
from the Command Prompt? You can. See this example for DNS:
netsh interface ip set dns "Local Area Connection" static 192.168.0.200
and this one for WINS:
netsh interface ip set wins "Local Area Connection" static 192.168.0.200
Or, if you want, you can configure your NIC to
dynamically obtain it's DNS settings
:
netsh interface ip set dns "Local Area Connection" dhcp
As you now see, Netsh.exe has many features you might find useful, and that goes beyond saying even without looking into the other valuable options that exist in the command.
 


用命令行设置windows的ip地址样例

  • 2008年09月16日 08:28
  • 250B
  • 下载

将命令行下设置IP地址进行到底!-netsh

原文:http://blogold.chinaunix.net/u2/79877/showart_2083368.html 一、添加 IP 地址及默认网关 (是添加,要重设或更新原来IP的请看第...

通过Windows命令行设置IP地址

最近在公司,在客户现场,在家里,使用不同的网络,经常要设置IP,每天要设置几次,很麻烦。 于是想到了“命令行+批处理+环境变量”的方法,这样设置IP不再是麻烦事了。 1. 在Windows中,常规...

Windows 命令行设置静态IP及DNS

Windows 命令行设置静态IP及DNS 有时候不得不使用静态IP连接网络,然而 “出现了一个意外的情况。不能完成所有你在设置中的所要求的更改。” 咋办??? 设置静态IP:    netsh ...
  • lzxomg
  • lzxomg
  • 2017年08月06日 22:01
  • 761

Windows命令行下配置IP地址

  • 2013年06月18日 10:14
  • 658B
  • 下载

用命令行netsh修改windows的ip、网关、dns

用命令行netsh修改windows的ip、网关、dns 分类: 技术文摘 2008-05-30 08:24 6296人阅读 评论(0) 收藏 举报 type 网络配置....
  • lionzl
  • lionzl
  • 2012年07月11日 22:06
  • 763

命令行下直接修改Windows2000的IP地址

有朋友问我,“能不能在命令行下直接修改Windows2000的IP地址?”。      呵呵,当然是可以的了。不仅可以修改IP地址,和网络相关的每个细节都可以用命令行方式进行配置。      ...

Windows下用命令行修改IP地址的方法详解(附批处理文件)

由于我所处的地方要经常在不同的网络之间切换,比如局域网、系统内部网和外网(光是外网我要常常在3个ADSL网之间切换)。我之前一直用的方法是在本机上设置多个不同网段的IP,然后切换路由(Route),这...

Windows用命令行修改ip地址以及wifi热点建立过程

要求写出Windows下用命令修改IP地址,wifi共享的设置方法
  • lyover
  • lyover
  • 2015年10月11日 23:02
  • 426

windows 系统下的命令行参考A-Z

  • 2009年04月29日 22:17
  • 251KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:windows下,用命令行进行系统的TCP/IP设置
举报原因:
原因补充:

(最多只允许输入30个字)