windows 网卡配置的设置命令

(1)设置为DHCP自动分配

netsh interface ip set address "本地连接"  dhcp

netsh interface ip set dns "本地连接"  dhcp

(2) 设置为静态IP信息

netsh interface ip set address "本地连接" static  10.10.2.1 255.255.255.0 10.10.2.254

netsh interface ip set dns "本地连接" static 114.114.114.114

netsh interface ip add dns "本地连接" 8.8.8.8 

(3)查看当前的IP配置信息

netsh interface ip show address/config/dns

(4)查看windows的网络配置文件

netsh -c interface dump 

(5)批处理的形式

echo #设静态IP
netsh interface ip set address name="本地连接" source=static addr=192.168.1.1 mask=255.255.255.0
echo #设默认网关
netsh interface ip set address name="本地连接" gateway=192.168.1.254 gwmetric=0
echo #设首选dns
netsh interface ip set dns name="本地连接" source=static addr=192.168.1.10 register=PRIMARY
echo #设备用dns
netsh interface ip add dns name="本地连接" addr=192.168.1.20 index=2
netsh interface ip set wins name="本地连接" source=static addr=none
echo #
echo #显示“本地连接”配置结果
netsh interface ip show config 本地连接
echo #
echo # "本地连接" 的接口 IP  配置
echo #设自动获取ip
netsh interface ip set address name="本地连接" source=dhcp 
echo #设自动获取dns
netsh interface ip set dns name="本地连接" source=dhcp register=PRIMARY
echo netsh interface ip set wins name="本地连接" source=dhcp

echo #显示“本地连接”配置结果
netsh interface ip show config 本地连接
echo # 接口 IP 配置结束

 (6)导出配置文件修改再执行导入

 netsh interface dump>网络配置.netsh

修改“网络配置.netsh”文件,保留、修改其中需要的pushd及popd段,及段中需要的行。
以后再在需要时修改配置:
netsh exec 网络配置.netsh

netsh 网络配置.netsh

 

①追加
DHCP : netsh interface ip set address name=Adapter source=DHCP
ip : netsh interface ip add address name=Adapter addr=ip mask=maskip gateway=gatewayip
DNS : netsh interface ip add DNS name=Adapter addr=DNSip
WINS : netsh interface ip add WINS name=Adapter addr=WINSip

 

②修正
DHCP : netsh interface ip set address name=Adapter source=DHCP
ip : netsh interface ip set address name=Adapter source=STATIC addr=ip mask=maskip gateway=gatewayip
DNS : netsh interface ip set DNS name=Adapter source=STATIC addr=DNSip
WINS : netsh interface ip set WINS name=Adapter source=STATIC addr=WINSip

 

③删除
ip : netsh interface ip delete address name=Adapter addr=ip
DNS : netsh interface ip delete DNS name=Adapter addr=DNSip
WINS: netsh interface ip delete WINS name=Adapter addr=WINSip

 

转载于:https://www.cnblogs.com/mountain2011/p/9005047.html

  • 0
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值