xxbdh's recent timeline updates
xxbdh

xxbdh

V2EX member #668562, joined on 2023-12-26 14:36:52 +08:00
xxbdh's recent replies
Dec 27, 2023
Replied to a topic by canitnamechange Bash 有个脚本代码的问题
根据你的描述,按照自己的理解,简单做了修改和简化。

@echo off & setlocal enabledelayedexpansion
PUSHD %~DP0
TITLE 双网卡配置脚本
mode con cols=60 lines=32
color 3e

set "routes=10.10.6.0 10.10.7.0 10.10.8.0 10.10.9.0 10.10.10.0 10.10.11.0 10.10.12.0 10.10.13.0 10.10.14.0 192.168.200.0 192.168.22.0 192.168.201.0"

:menu
cls
echo.
echo. 请选择所处内网网段
echo ---------------------------
echo.
set _id=
for %%s in (%routes%) do (
set /a _id+=1
echo !_id! %%s
set _route=%%s
set gateway#!_id!=!_route:~0,-2!.1
)
echo.
echo.
echo q 退出
echo.
echo d 删除路由表
echo.
echo ---------------------------
echo.
set /p ID= 请输入序号:

if /i "%ID%"=="q" goto :eof
if /i "%ID%"=="d" goto delete_routes
if not defined gateway#%ID% goto menu

:add_routes
for %%a in (%routes%) do (
route -p add %%a mask 255.255.255.0 !gateway#%ID%!
echo 已添加路由: %%a !gateway#%ID%!
)

echo. 添加完成
timeout /t 50 >nul
goto menu

:delete_routes
for %%r in (%routes%) do (
route delete %%r
echo 已删除路由: %%r
)
echo. 删除完成
timeout /t 1 >nul
goto :menu
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5820 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 32ms · UTC 02:21 · PVG 10:21 · LAX 19:21 · JFK 22:21
♥ Do have faith in what you're doing.