#!/usr/bin/env python3 import ipaddress def generate_commands(start_port, start_subnet, start_ip, count): ip = ipaddress.ip_address(start_ip) commands = [] for i in range(count): port = start_port + i subnet_num = 65 + i # 从 10.65.0.0/16 开始 subnet = f"10.{subnet_num}.0.0/16" gateway = f"10.{subnet_num}.0.1" use_ip = str(ip + i) cmd = (f"nohup /root/server_tun/server --port {port} " f"--subnet {subnet} " f"--gateway {gateway} " f"--use-ip {use_ip} " f"> /root/server_tun/{port}.log 2>&1 &") commands.append(cmd) return commands if __name__ == "__main__": # 参数配置 START_PORT = 5715 START_IP = "45.86.235.163" COUNT = 20 cmds = generate_commands(START_PORT, 65, START_IP, COUNT) for c in cmds: print(c)