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下,用命令行进行系统的TCP/IP设置

In order to configure TCP/IP settings such as the IP address, Subnet Mask, Default Gateway, DNS and ...
  • fgwf1
  • fgwf1
  • 2004年11月05日 09:37
  • 1319

windows 脚本设置多IP

毫无疑问,在windows中设置IP非常方便,因为有简单直观的界面可供操作。通过图形用户界面设置IP在一般情况下是够用的,但是对于那些经常出差,变换工作产所的人来说,这样修改IP无疑是耗时且不方便的。...
  • hongweigg
  • hongweigg
  • 2014年07月08日 23:10
  • 5127

系统常用服务命令列表(转)

appwiz.cpl------------添加删除程序 control userpasswords2--------用户帐户设置 cleanmgr-------垃圾整理 CMD-----------...
  • guyehanxinlei
  • guyehanxinlei
  • 2007年06月20日 14:49
  • 484

C++6.0行号显示插件的安装和 字体设置问题

1.下载VC6LineNumberAddin插件及注册文件。   2.解压把拷贝VC6LineNumberAddin.dll到VC6安装路径下的AddIns文件夹,笔者的完整路径为:D:/...
  • meetings
  • meetings
  • 2015年02月01日 23:42
  • 1120

在windows下如何用命令行启动程序

看到那种桌面上密密麻麻全是跨界方式和文件夹的显示器,总是一阵蛋蛋的忧伤,一个是想找某个图标要找很久,而且只要使用电脑的时间够长,桌面上肯定不够放置所有程序的快捷方式,那时每装一个程序,都要纠结替换桌面...
  • u012519969
  • u012519969
  • 2014年03月12日 10:06
  • 2472

TCP/IP 在 Windows 下的实现

Windows 下是怎么实现 TCP/IP 协议族的,这篇文章以 UDP 的实现为例,对这个过程进行了简单的说明。...
  • Henzox
  • Henzox
  • 2014年08月29日 17:26
  • 4903

windows 下监测TCP/IP通信

/****************************************************************** * *  windows下监测Tcp/Ip通信  * *  Au...
  • sjf331
  • sjf331
  • 2005年08月08日 13:45
  • 1527

用命令行加载驱动

以下是微软帮助文件中对sc命令的描述:与“服务控制器”和已安装设备进行通讯。SC.exe 检索和设置有关服务的控制信息。可以使用 SC.exe来测试和调试服务程序。可以设置存储在注册表中的服务属性来控...
  • hktk001
  • hktk001
  • 2009年10月24日 14:22
  • 1690

在 Eclipse 中使用命令行

虽然我们已经有了像 Eclipse 这样高级的 IDE,但是我们有时候也是需要在开发的时候使用 Windows 的命令行,来运行一些独立的程序。在两个程序中切换来切换去是很麻烦的。所以 Eclipse...
  • a457886115
  • a457886115
  • 2016年03月09日 18:04
  • 235

用命令行方式进行WIndows的网络设置

2007-01-22     在我住的公寓上网,用的是自动获取IP,而在学校用的是固定IP。这样每次我从住所来到学校后,为了重新更换IP,网关,以及DNS,都不得不费力地敲入一系列数值在0-255之...
  • neweroica
  • neweroica
  • 2007年06月30日 23:48
  • 1395
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:windows下,用命令行进行系统的TCP/IP设置
举报原因:
原因补充:

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