网站首页 > 教程文章 正文
一、添加 IP 地址及默认网关 (是添加,要重设或更新原来IP的请看第三点)
netsh interface ip add address
用法 : add address [name=]<string> [[addr=]IP address [mask=]IP subnet mask]
[[gateway=]IP address [gwmetric=]integer]
参数 :
name - IP 接口名称。
addr - 要添加到此接口的 IP 地址。
mask - 指定 IP 地址的 IP 子网掩码。
gateway - 指定 IP 地址的默认网关。
gwmetric - 默认网关的跃点数。
注释 : 向一个用静态 IP 地址配置的接口添加 IP 地址和
默认网关。
示例 :
add address "Local Area Connection" 10.0.0.2 255.0.0.0
add address "Local Area Connection" gateway=10.0.0.3 gwmetric=2
第一个命令向本地连接接口添加一个静态 IP 地址 10.0.0.2 ,子网掩码
为 255.0.0.0 。第二个命令向网关跃点数为 2 的接口添加 IP 地址
10.0.0.3 作为第二个默认网关。
我的实例 :
(1)netsh interface ip add address "LocalConnection" 172.20.0.49 255.255.252.0
此命令设置 LocalConnection 的 IP 为 172.20.0.49, 子网掩码为 255.255.252.0
(2)
C:\>netsh interface ip add address "LocalConnection" gateway=172.20.0.254 gwmetric=1
此命令设置 Localconnection 的默认网关为 172.20.0.254, 默认网关的跃点数为 1
二、添加 DNS
netsh interface ip add dns ?
用法 : add dns [name=]<string> [addr=]<IP address> [[index=]integer]
参数 :
标记 数值
name - 添加 DNS 服务器的接口的名称。
addr - 添加的 DNS 服务器的 IP 地址。
index - 为指定的 DNS 服务器地址
指定索引 ( 首选项 ) 。
说明 : 静态添加新的 DNS 服务器 IP 地址或重新索引现有 DNS 服务器地址的列表以修改 DNS 服务器首选项。
例如 :
add dns "Local Area Connection" 10.0.0.1
add dns "Local Area Connection" 10.0.0.3 index=2
我的实例:
netsh interface ip add dns "LocalConnection" 172.20.0.1
netsh interface ip add dns "LocalConnection" 202.96.128.68 index=2
三、设置 IP 地址、默认网关及 DNS :
netsh interface IP set address local static 172.20.0.49 255.255.252.0 设置 IP 及子网掩码
netsh interface IP set address local static gateway=172.20.0.254 gwmetric=1
(set address name="LocalConnection" source=dhcp 此条表示从 dhcp 服务器得到 IP)
netsh interface IP set dns "LocalConnection" static 172.20.0.1
(set dns name="LocalConnection" source=dhcp)
四、综合例
netsh interface IP set address local static 172.20.0.49 255.255.252.0
netsh interface IP set address local static gateway=172.20.0.254 gwmetric=1
netsh interface IP set dns "LocalConnection" static 172.20.0.1
netsh interface ip add dns "LocalConnection" 202.96.128.68 index=2
以上命令做成批处理:
edit setIP.bat
netsh interface IP set address local static %2 255.255.252.0
netsh interface IP set address local static gateway=172.20.0.254 gwmetric=1
netsh interface IP set dns "%1" static 172.20.0.1
netsh interface ip add dns "%1" 202.96.128.68 index=2
setIP.bat 的命令用法是:
setIP 网络接口名 IP 地址
例如:
setip LocalConnection 172.20.0.49
- 上一篇: Windows下使用netsh命令设置ip和wifi网络
- 下一篇: 一台电脑同时上内网和外网
猜你喜欢
- 2024-12-08 Linux网络调试助手
- 2024-12-08 windows系统使用VPN后设置内、外网路由分离
- 2024-12-08 一台电脑同时上内网和外网
- 2024-12-08 Windows下使用netsh命令设置ip和wifi网络
- 2024-12-08 一个比 ping 更强大、更牛逼的命令行工具!
- 2024-12-08 测试网络路由路径工具:Tracert命令
- 2024-12-08 内外网卡共用教程
- 2024-12-08 IT人员必须要掌握的几个网络测试命令详解
- 2024-12-08 有wifi和有线网络,教你指定网站用指定网络访问从而绕过屏蔽
- 2024-12-08 办公室上网攻略--内网、外网、路由,自主控制
- 最近发表
- 标签列表
-
- location.href (44)
- document.ready (36)
- git checkout -b (34)
- 跃点数 (35)
- 阿里云镜像地址 (33)
- qt qmessagebox (36)
- md5 sha1 (32)
- mybatis plus page (35)
- semaphore 使用详解 (32)
- update from 语句 (32)
- vue @scroll (38)
- 堆栈区别 (33)
- 在线子域名爆破 (32)
- 什么是容器 (33)
- sha1 md5 (33)
- navicat导出数据 (34)
- 阿里云acp考试 (33)
- 阿里云 nacos (34)
- redhat官网下载镜像 (36)
- srs服务器 (33)
- pico开发者 (33)
- https的端口号 (34)
- vscode更改主题 (35)
- 阿里云资源池 (34)
- os.path.join (33)