返回列表 回复 发帖

小小技巧,批处理修改本地IP和DNS

之前由于家里和公司的上网方式不一样,家里的IP是自动获取的,而公司要静态配置的,所以每次电脑拿回去或到公司都要手工点击网络连,再一个个数字打进去,配置一遍IP和DNS,实在是太麻烦了。还好查了查资料,发现命令行下的功能好强,修改什么都可以。下面是我的两个配置文件。如果要修改IP,只要双击文件就可以了。5 O5 B1 h9 n" Q* F& k

: [3 p; ^. R5 X- W$ l6 b家里IP.bat
* [% F% |* R( t" C0 v" O0 C
+ c, ]: u/ \1 o! Z" V: r9 T 程序代码
: Q( f% R; Y1 G0 f4 I
% |8 _: @* s: d  e( Inetsh interface ip set address name="本地连接" source=dhcp
' E- H' ^- J5 l5 m  wipconfig /flushdns
5 L5 l5 o1 ~4 y$ o  y" c: R$ ^2 X. n0 n  Q4 |$ t4 w

! ?% `( r0 s8 s' U/ _3 v3 @% T$ @: \- l; U
公司IP.bat
3 V' B) M: M$ `' j% }5 b# R' \
0 a# N0 o  S4 W  j9 _& _. a 程序代码
: M- b; g: h9 _# _! D. m" C/ r' c  n+ g- }6 U' L' p* U3 O
netsh interface ip delete dns "本地连接" addr=all
6 f( K1 W+ Q* v: x. f0 H) ^netsh interface ip add dns "本地连接" addr=202.101.172.353 X" P# {" W# N- ^& Y7 \
netsh interface ip add dns "本地连接" addr=202.101.172.36! e" M% r# w+ i1 |
netsh interface ip add address "本地连接" 192.168.0.133 255.255.255.0# g. p. a* r: h
netsh interface ip add address "本地连接" gateway=192.168.0.1 gwmetric=2
4 a9 d: ^4 ?$ g# Cipconfig /flushdns
' y8 U3 x- \8 ~2 j5 E3 g$ P7 i' T3 a, N' \) x: g
+ z: _' f7 g4 U6 [7 U

% T3 M4 u! r  s呵,这样一来,感觉方便多了。。
返回列表