IP及DNS设置(Netsh)
#根据连接状态查找使用中网卡
gwmi win32_networkadapter -filter "NetConnectionStatus = 2"
#根据是否配置网关查找使用中网卡
$index = (gwmi Win32_NetworkAdapterConfiguration |?{ $_.DefaultIPGateway -ne $null}).Index
$ConnectionID = (gwmi win32_networkadapter -filter "index = $index").NetConnectionID
$ConnectionID
#查找loopback网卡
$index_lb = (gwmi Win32_NetworkAdapterConfiguration | ? {$_.Description -eq "Microsoft Loopback Adapter"}).index
######################################################################
#禁用/启用网卡
netsh.exe interface set interface "$ConnectionID" disabled
netsh.exe interface set interface "$ConnectionID" enabled
设置静态IP及DNS:
netsh interface ip set address "Wi-Fi" source=static addr=192.168.1.234 mask=255.255.255.0 gateway=192.168.1.2
netsh interface ip set dnsservers "Wi-Fi" static 8.8.8.8 primary validate=no 设置第一个DNS地址
添加多个DNS:
netsh interface ip add dnsservers "Wi-Fi" 202.106.0.20 index=2 validate=no 添加第二个DNS地址(注:如果index=1,则变为第一个DNS地址,原第一个下移)
netsh interface ip add dnsservers "Wi-Fi" 202.106.0.21 index=3 validate=no 添加第三个DNS地址
设置动态IP:
netsh interface ip set address "Wi-Fi" source=dhcp
netsh interface ip set dnsservers "Wi-Fi" source=dhcp
Windows Server 2003:
netsh interface ip set dns "本地连接 4" static 100.40.2.53 primary
netsh interface ip add dns "本地连接 4" 100.40.2.54 index=2
netsh interface ip add dns "本地连接 4" 219.232.48.61 index=5
netsh interface ip add dns "本地连接 4" 202.106.196.115 index=6
ipconfig /all
IP及DNS设置(Netsh)的更多相关文章
- centos6.5静态IP和DNS设置
sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0EVICE=eth0HWADDR=60:02:92:62:30:2ATYPE=EthernetBROA ...
- 批处理文件设置IP以及DNS
先附上批处理文件代码(批处理文件怎么创建自己另行百度,这里不再赘述) Echo offecho ==============请输入序号修改办公区===========echo *********1.家 ...
- 利用netsh命令设置IP地址/DNS服务器地址
一.设置IP地址 1. 自动获取IP地址: netsh interface ip set address [name=]"本地连接" [source=]dhcp 2. 手动设置IP ...
- .bat文件设置IP、DNS
这几天遇到个烦心事,每次开机之后都要去手动去设置一下IP地址,一大串的数字还是有点麻烦,于是就想写个批处理文件设置IP 注意:在DOS下设置IP时需要管理员权限运行 1.查看机子设置IP需要用到的名字 ...
- 本地IP,掩码,网关,DNS设置
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- windows命令行设置IP与DNS
用dos命令修改IP等本地连接属性 平时我们改IP通常都在是窗口界面本地连接直接修改, 那在命令行也可以设置IP地址?当然可以,这里要用到netsh命令 .点击“开始”->“运行”,输入“cmd ...
- 设置自动获取IP和DNS
问题阐述 设置ipv4的自动获取时遇到一个问题,ip和dns自动获取可以确认设置,但是全局时就是报错,回头去看ipv4的ip和dns也还是原来的样子 由于一直使用的都是自动获取,很少会有主动设置ip或 ...
- Centos6.2设置静态ip和dns
参考了如下文章:https://gist.github.com/fernandoaleman/2172388http://www.lifelinux.com/how-to-configure-stat ...
- Centos 7 安装 设置 IP地址,DNS,主机名,防火墙,端口,SELinux (实测+笔记)
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.虚拟系统安装 1.1 使 ...
随机推荐
- VS2013诡异问题,虚方法、泛型,通通躺枪
最近在调代码,发现一个很诡异的问题,简单复原一下 创建4.0控制台项目 以下代码 class Program { static void Main(string[] args) { var item ...
- input输入框中只能输入数字,非数字字符自动清除
前言:项目中有个缴纳保证金的功能,要是输入框只能输入数字,不能输入其他字符. ①HTML代码:<input class="input-box" type="text ...
- Android控件之ListView的使用
ListView是Android当中一个非常常用的数据显示控件. 第一种可以使用List<HashMap<String , Object>>,作为适配器的数据源来显示要显示的数 ...
- ZOJ 3607 Lazier Salesgirl
Kochiya Sanae is a lazy girl who makes and sells bread. She is an expert at bread making and selling ...
- 为easyui添加多条件验证
easyui的验证框架,validatebox不能有效的支持多个条件的验证,比如中文用户名,既要验证其是中文,又要验证其长度不超过6位时便显得很繁琐,需要反复的为easyui添加验证规则. 在此实现一 ...
- unity对敏感词库处理的记录
string txt = Resources.Load<TextAsset>("minganci").ToString(); //string txt = " ...
- LoadRunner使用
LoadRunner使用 软件版本:12.53 build 1203 操作系统: Windows7 以下内容摘录自LoadRunner的官方帮助文档. 介绍 LoadRunner现在是HP公司的产品, ...
- 快速清除SQL2008日志文件
USE [master] --把数据库调整为简单模式 GO ALTER DATABASE krisvision SET RECOVERY SIMPLE WITH NO_WAIT GO ALTER DA ...
- ubuntu基本配置学习(1)
[转载]源自:http://www.haogongju.net/art/2048612 附加另外一篇文章:http://www.cnblogs.com/vincent-hv/archive/2013/ ...
- after() 和 remove() 实现替换
<div class="replacedDiv">this is the replaced div</div> <script> ...