Here are two scripts, which function as switching network configuration
under windows. The first one will configure network interface by dhcp;
while the other one will configure network interface statically. They
both are run by netsh. The command line looks like: netsh exec
net-switch-dhcp.sh.
net-switch-dhcp.sh
==============================
# net-switch-dhcp.sh
# configure network interface by dhcp
# ----------------------------------
# 接口 IP 配置
# ----------------------------------
pushd interface ip
# "本地连接" 的接口 IP 配置
set address name="本地连接" source=dhcp
set dns name="本地连接" source=dhcp register=PRIMARY
set wins name="本地连接" source=dhcp
popd
# 接口 IP 配置结束
==============================
then, net-switch-static.sh
==============================
# net-switch-static.sh
# configure network interface statically
# ----------------------------------
# 接口 IP 配置
# ----------------------------------
pushd interface ip
# "本地连接" 的接口 IP 配置
set address name="本地连接" source=static addr=192.168.1.84 mask=255.255.255.0 gateway=192.168.1.50 gwmetric=1
set dns name="本地连接" source=static addr=192.168.1.50 register=PRIMARY
set wins name="本地连接" source=dhcp
popd
# 接口 IP 配置结束
==============================
That's all.
阅读(1303) | 评论(0) | 转发(0) |