自动配置IP地址.bat

  1. ※※※※※※※※※※※※※※※※※※※※※※※※※※※※
  2. @echo     ※                                                    ※
  3. @echo     ※    本命令用于自动设置无线网络和本地连接的IP地址    ※
  4. @echo     ※                                                    ※
  5. @echo     ※                                                    ※
  6. @echo     ※ 1 - 设置无线网络地址为192.168.1.123,用于公司上网  ※
  7. @echo     ※                                                    ※
  8. @echo     ※ 2 - 设置无线网络地址为自动获取,用于外部上网       ※
  9. @echo     ※                                                    ※
  10. @echo     ※ 3 - 设置本地连接地址为192.168.2.23,用于集中器连接 ※
  11. @echo     ※                                                    ※
  12. @echo     ※ 4 - 设置本地连接地址为自动获取,用于外部上网       ※
  13. @echo     ※                                                    ※
  14. @echo     ※※※※※※※※※※※※※※※※※※※※※※※※※※※※
  15. @echo.
  16. @echo.
  17. @echo.
  18. @echo     ******请选择设置方式[1,2,3,4],并按回车确定执行******
  19. @echo.
  20. @echo.
  21. @echo.
  22. @echo.
  23. @ SET /P ST="方式选择: "
  24. echo.
  25. if /I "%ST%"=="1" goto setip1
  26. if /I "%ST%"=="2" goto setip1no
  27. if /I "%ST%"=="3" goto setip2
  28. if /I "%ST%"=="4" goto setip2no
  29. :setip1
  30. cls
  31. @echo.
  32. @echo         ---------------------------------------------
  33. @echo         本命令将自动为“无线网络连接”填写以下内容:
  34. @echo                  IP地址:  192.168.1.123
  35. @echo                  子网掩码:255.255.255.0
  36. @echo                  网关:    192.168.1.1
  37. @echo.
  38. @echo                  首选DNS:  61.144.56.100
  39. @echo                  备用DNS:  61.144.56.101
  40. @echo         ---------------------------------------------
  41. @echo.
  42. @echo.
  43. @echo.
  44. @echo.
  45. @echo.
  46. @ pause
  47. @echo 设置IP地址...
  48. @echo off
  49. netsh interface ip set address name="无线网络连接" source=static addr=192.168.1.123 mask=255.255.255.0 gateway=192.168.1.1 1
  50. @echo 设置首先DNS...
  51. @echo off
  52. netsh interface ip set dns name="无线网络连接" source=static addr=61.144.56.100
  53. @echo 设置备用DNS...
  54. @echo off
  55. netsh interface ip add dns "无线网络连接" 61.144.56.101 index=2
  56. @echo 设置完成。
  57. @ pause
  58. exit
  59. :setip1no
  60. cls
  61. @echo.
  62. @echo         ----------------------------------------
  63. @echo         本命令将自动为“本地连接”填写以下内容:
  64. @echo.
  65. @echo                      自动获取IP地址
  66. @echo                  自动获取DNS服务器地址
  67. @echo         -----------------------------------------
  68. @echo.
  69. @echo.
  70. @echo.
  71. @echo.
  72. @ pause
  73. @echo.
  74. @echo off
  75. @echo 设置自动获取IP地址...
  76. netsh interface ip set address name="无线网络连接" source=dhcp
  77. @echo 设置自动获取DNS服务器地址...
  78. netsh interface ip set dns name="无线网络连接" source=dhcp
  79. @echo.
  80. @echo 设置完成。
  81. @ pause
  82. exit
  83. :setip2
  84. cls
  85. @echo.
  86. @echo         ---------------------------------------------
  87. @echo            本命令将自动为“本地连接”填写以下内容:
  88. @echo                  IP地址:  192.168.2.23
  89. @echo                  子网掩码:255.255.255.0
  90. @echo         ---------------------------------------------
  91. @echo.
  92. @echo.
  93. @echo.
  94. @echo.
  95. @echo.
  96. @ pause
  97. @echo.
  98. @echo off
  99. @echo 设置IP地址...
  100. netsh interface ip set address name="本地连接" source=static addr=192.168.2.23 mask=255.255.255.0
  101. @echo 设置自动获取DNS服务器地址...
  102. netsh interface ip set dns name="本地连接" source=dhcp
  103. @echo 设置完成
  104. @echo.
  105. @ pause
  106. exit
  107. :setip2no
  108. cls
  109. @echo.
  110. @echo         ----------------------------------------
  111. @echo         本命令将自动为“本地连接”填写以下内容:
  112. @echo.
  113. @echo                      自动获取IP地址
  114. @echo                  自动获取DNS服务器地址
  115. @echo         -----------------------------------------
  116. @echo.
  117. @echo.
  118. @echo.
  119. @echo.
  120. @ pause
  121. @echo.
  122. @echo off
  123. @echo 设置自动获取IP地址...
  124. netsh interface ip set address name="本地连接" source=dhcp
  125. @echo 设置自动获取DNS服务器地址...
  126. netsh interface ip set dns name="本地连接" source=dhcp
  127. @echo.
  128. @echo 设置完成。
  129. @ pause
  130. exit
上一篇:ARM-Linux配置DHCP自动获取IP地址


下一篇:Linux下查看CPU、内存和硬盘信息命令