The solution is actually very simple — the NETSH.EXE utility, built into the operating system, will help us.
Static address
netsh interface ip set address name="Подключение по локальной сети" source=static addr=192.168.0.2 mask=255.255.255.0 gateway=192.168.0.1 gwmetric=1
netsh interface ip set dns "Подключение по локальной сети" static 192.168.0.1
netsh interface ip add dns "Подключение по локальной сети" 8.8.8.8
Dynamic address
netsh interface ip set address name="Подключение по локальной сети" source=dhcp
netsh interface ip set dns name="Подключение по локальной сети" source=dhcp
To switch settings on a laptop, you can simply create a couple of bat files and specify your own parameters for each network.
This can also be done with a single file if you set up a user interaction interface, but in some sense that's already overkill.
Attention! Administrator rights are required to change adapter settings! So the bat file must be run as administrator, otherwise the script will display a message about insufficient rights and close the console window, and you'll never find out why it didn't work.
Comments