TOM快跑综合论坛

首页 » IT版块 » TOM快跑---电脑技术 » Windows网络环境切换常用命令
摩托 - 2008-7-30 16:51:00
简单总结一下用Windows命令行设置常用网络配置的命令。将它们保存为批处理文件(.bat),方便笔记本电脑用户在不同网络环境下快速切换配置。一、设置IP与DNS›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
1、设置为DHCP:›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
cmd /c netsh interface ip set address name="Local Area Connection" source=dhcp gwmetric=0›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
cmd /c netsh interface ip set dnsserver name="Local Area Connection" source=dhcp›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
(中文系统下“Local Area Connection”应替换为“本地连接”一类的名称,下同)›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
2、设置为固定IP:›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
cmd /c netsh interface ip set address name="Local Area Connection" source=static addr=10.2.54.123 mask=255.255.255.0 gateway=10.2.54.1 gwmetric=1›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
3、设置多个DNS服务器:›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
cmd /c netsh interface ip set dnsserver name="Local Area Connection" source=static addr=10.87.130.1›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
cmd /c netsh interface ip add dnsserver name="Local Area Connection" 10.87.130.2›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
二、设置主机名解析文件›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
有时候可能需要针对不同的环境使用不同的主机名解析文件,以便在不修改其它软件配置的情况下使用统一的域名访问不同的服务。›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
copy E:\Program\Batches\netenv\hosts.1 C:\Windows\System32\drivers\etc\hosts 或›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
copy E:\Program\Batches\netenv\hosts.2 C:\Windows\System32\drivers\etc\hosts›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
“hosts.1”文件内容:›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
127.0.0.1      localhost›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
10.87.1.1      mail_host.linjian.org›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
“hosts.2”文件内容:›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
127.0.0.1      localhost›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
202.204.80.1    mail_host.linjian.org›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
三、设置路由表›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
在局域网内同时使用两种外网登录工具(如“亿邮”+“教育网直通车”)时可能有用。›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
添加:›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
route -p add 10.0.0.0 mask 255.0.0.0 10.2.54.1›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
删除:›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
route delete 10.0.0.0›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
四、设置代理服务器›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
可以将不同网络环境下的代理服务器配置存储在不同的注册表文件中,需要改变的时候导入注册表。›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
reg import E:\Program\Batches\netenv\proxy.reg 或›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
reg import E:\Program\Batches\netenv\noproxy.reg›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
“proxy.reg”文件内容:›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
Windows Registry Editor Version 5.00›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
"ProxyEnable"=dword:00000001›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
"ProxyHttp1.1"=dword:00000001›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
"ProxyOverride"="<local>"›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
"ProxyServer"="60.28.31.194:80"›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
“noproxy.reg”文件内容:›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
Windows Registry Editor Version 5.00›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
"ProxyEnable"=dword:00000000›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
五、ADSL或VPN接入›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
连接:›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
rasdial Entryname Username Password›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
断开:›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
rasdial Entryname /DISCONNECT›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
  组合调用上述命令,建立适用于不同环境下的网络配置批处理文件。最后,别忘了修改批处理文件(或其快捷方式)的属性,让它默认以Administrator身份运行,这样才能保证上述设置有权限执行。›…Pۅª„àbbs.tomrun.netç4ux ôhMÉ
1
查看完整版本: Windows网络环境切换常用命令