Quick change network settings

    I use my personal laptop at work and at home. To access the network, I have to change the network settings twice a day. Moreover, both at home and in the office there is a binding to the MAC address of the machine. Therefore, you also have to change the MAC in the properties of the network card.
    To somehow automate this process, a command line and a search engine were launched. Details and the finished bat-file under the cut.

    Introduction

    To change IP, the netsh utility is on the windows command line. More about what it is and what it is eaten on the wiki with .
    To change the MAC address, I did not find standard tools (if there are any, specify, I will be grateful). Therefore, I used the Macshift program. You can download it from the official site .

    Batik lessons

    Create a network.bat file with the contents: Pay attention to the beginning of the file, after the dom and rabota labels, enter your settings. Note: "echo _____" is used exclusively from aesthetic undertakings.
    @echo off
    set /p mesto="Выберите настройки (1 - дом, 2 - работа): "
    echo Выбраны настройки - %mesto%

    if %mesto% equ 2 goto rabota

    :dom
    set IFACE="local"
    set IP=10.160.100.9
    set MASK=255.255.255.0
    set GATEWAY=10.160.100.1
    set GWMETRIC=1
    set DNS1=10.160.100.1
    set MAC=001122334455
    goto smena

    :rabota
    set IFACE="local"
    set IP=192.168.1.91
    set MASK=255.255.255.0
    set GATEWAY=192.168.1.1
    set GWMETRIC=1
    set DNS1=192.168.1.10
    set MAC=221133004455
    goto smena

    :smena
    echo Меняем MAC адрес на %MAC%
    echo _____
    macshift -i "local" %MAC%

    echo _____
    echo Устанавливаем IP адрес-%IP%
    echo Маску подсети-%MASK%
    echo Основной Шлюз-%GATEWAY%

    netsh interface ip set address name=%IFACE% source=static addr=%IP% mask=%MASK% gateway=%GATEWAY% gwmetric=%GWMETRIC%

    echo Устанавливаем основной DNS сервер %DNS1%
    netsh interface ip set dns name=%IFACE% source=static addr=%DNS1% register=PRIMARY

    echo Настройки сети изменены:
    ipconfig /all
    echo _____
    pause





    Last preparations

    I placed the macshift program and the batch file in d: \ program \ network. And on the desktop brought out a shortcut to network.lnk. When you launch the shortcut, the batch file starts with the question of choosing settings. By clicking "1", we get the settings for the house, respectively, "2" - for the office.
    Maybe someone will find this topic useful.

    Also popular now: