---
title: "Windows切换IP网关脚本"
author: "iammonster"
date: "2009-12-16T18:16:55Z"
tags: []
categories: ["操作系统"]
slug: "windows-ip"
draft: false
lastmod: "2009-12-16T18:16:55Z"
id: 549979
url: "https://jiajun.iteye.com/blog/549979"
---

方便生活，来个备份手册：Windows切换IP和网关的脚本

 

```
netsh interface ip set address "本地连接" source=static addr=192.168.0.125 mask=255.255.255.0
netsh interface ip add address "本地连接" 192.168.0.125 255.255.255.0
netsh interface ip add address "本地连接" 192.168.0.126 255.255.255.0
netsh interface ip add address "本地连接" 192.168.0.127 255.255.255.0
netsh interface ip add address "本地连接" 192.168.0.128 255.255.255.0
netsh interface ip add address "本地连接" 192.168.0.129 255.255.255.0

netsh interface ip set address name="本地连接" gateway=192.168.0.253 gwmetric=1
netsh interface ip add address name="本地连接" gateway=192.168.0.254 gwmetric=2

netsh interface ip set dns name="本地连接" source=static addr=192.168.0.253
netsh interface ip add dns "本地连接" 192.168.0.254

pause
```

 

```
netsh interface ip set address "本地连接" source=static addr=192.168.1.100 mask=255.255.255.0

netsh interface ip set address name="本地连接" gateway=192.168.1.1 gwmetric=1

pause
```