• Set IP address with DOS command


    Please try to save these text below as a *.bat file, then excute it, you will be able to set the IP address on your local PC in a simply way:

    ==================== IP Address Configruation Batch Process Source ==========================

    @echo off
    title IP自动设置
    MODE con: COLS=80 lines=30
    color 0a

    :main
    cls

    echo IP Manager Tool
    echo.
    echo 要把IP设置为公司用的IP 请按 1
    echo 要把IP设置为自动获取 请按 2
    echo 要退出 请按 3
    echo.

    set /p choice=          你的选择:

    echo.

    if "%choice%"=="1" goto ip1
    if "%choice%"=="2" goto ip2
    if "%choice%"=="3" goto end
    if "%choice%"=="4" goto test

    goto main

    :ip1
    echo  IP自动设置开始....
    echo.

    echo      正在设置IP, 子网掩码, 网关地址
    netsh interface ip set address "本地连接" static 10.10.120.121 255.0.0.0 10.10.120.8
    @rem 以上这句是设置IP为10.10.120.121 子网掩码为255.0.0.0 网关为10.10.120.8

    echo      正在设置DNS服务器
    netsh -c interface ip set dns name="本地连接" source=static addr=10.10.120.8 register=PRIMARY
    @rem 以上这句为设置DNS为10.10.120.8

    echo      正在设置备用DNS服务器
    netsh -c interface ip add dns name="本地连接" addr=10.10.120.11
    @rem 以上这句为设置备用DNS为10.10.120.8

    echo      设置完成
    echo.
     
    CHOICE /C YN /M "退出请按 Y,返回菜单请按 N。"

    if errorlevel 2 goto main
    if errorlevel 1 goto end


    :ip2
    echo  IP自动设置开始....
    echo.
    echo  自动获取IP地址....
    netsh interface ip set address name = "本地连接" source = dhcp
    echo  自动获取DNS服务器....
    netsh interface ip set dns name = "本地连接" source = dhcp

    @rem 设置自动获取IP
    echo      设置完成
    echo. 
    CHOICE /C YN /M "退出请按 Y,返回菜单请按 N。"

    if errorlevel 2 goto main
    if errorlevel 1 goto end

    :test
    netsh interface ip set address name = "本地连接" source = dhcp

    netsh interface ip set dns name = "本地连接" source = dhcp

    netsh interface ip set wins name = "本地连接" source = dhcp

    CHOICE /C YN /M "退出请按 Y,返回菜单请按 N。"

    if errorlevel 2 goto main
    if errorlevel 1 goto end

    :end

  • 相关阅读:
    《软件工程课程总结》
    课后作业-阅读任务-阅读笔记-4
    两个不同的网络,进行数据同步的设计思路
    IDEA清理缓存项目
    IDEA快捷键
    IDEA如何添加多个maven项目工程
    sqlserver数据库中的mdf文件太大,表空间分析和表空间释放
    关于AOP的面向切面编程
    关于.net进行爬虫
    关于调用别人接口的一些问题总结
  • 原文地址:https://www.cnblogs.com/chenjunsheep/p/2150556.html
Copyright © 2020-2023  润新知