file-type

一键配置多网卡IP的Win批处理工具介绍

版权申诉

RAR文件

1KB | 更新于2025-08-07 | 119 浏览量 | 0 下载量 举报 收藏
download 限时特惠:#14.90
标题 "NET_Config_TCP/IP_windows_" 指明了文档内容的主题范围,即涉及Windows操作系统下的TCP/IP网络配置,特别是在使用批处理文件(batch file,通常具有.bat扩展名)进行网络配置方面。该主题表明将会探讨如何通过Windows批处理技术来设置和管理TCP/IP网络参数。 描述中提到的“Win批处理bat文件,多网卡IP一键配置功能”,说明了文档将讨论如何使用Windows平台的批处理脚本实现网络配置自动化,尤其是对于安装有多块网络接口卡(NICs)的计算机。在这种场景下,系统管理员或高级用户能够通过一个简单的批处理脚本来快速配置或更改网络接口卡的IP设置。 描述还提到了“可选择单个网卡启用或不启用,IPConfig功能”,这意味着文档将涵盖如何控制特定网卡的启用状态,以及利用Windows内置的网络配置工具“IPConfig”来进行网络配置。IPConfig是Windows环境下一个重要的网络配置工具,用于显示当前网络接口的状态,比如分配给计算机的IP地址、子网掩码、默认网关等信息。此外,通过批处理脚本调用IPConfig,可以实现对网络设置的批量更改,提高管理效率。 标签 "TCP/IP windows" 表明,文档将集中在Windows操作系统环境下TCP/IP网络协议栈的配置与应用上。TCP/IP(Transmission Control Protocol/Internet Protocol)是一种在Internet中广泛使用的标准通信协议,Windows操作系统提供了对TCP/IP协议的原生支持和管理工具。理解TCP/IP在Windows中的配置是网络管理和故障排除的基础。 压缩包子文件的文件名称列表中只有一个条目:“NET_Config.bat”,这个名字暗示了这将是脚本文件的名称。文件名中的“NET_Config”可能代表了“网络配置”的缩写。批处理文件通常用来执行一系列的命令,它们对于重复性任务和批处理操作非常有用。在该场景下,NET_Config.bat很可能是用来执行网络配置命令的脚本。 针对上述信息,可以提炼出以下知识点: 1. 批处理文件(Batch file)基础:批处理文件是文本文件的一种,包含了为执行命令行指令而编写的命令序列。它们以.bat作为文件扩展名,在Windows操作系统中通过命令提示符执行。批处理文件可用来自动化常规任务,如系统管理、软件部署以及网络配置等。 2. Windows平台的网络配置:在Windows环境下,网络配置可以通过多种方式实现,包括使用图形用户界面(GUI)的“控制面板”中的“网络和共享中心”,以及命令行工具如IPConfig和Netsh。 3. IPConfig工具的使用:IPConfig是一个非常强大的命令行工具,用于显示当前网络接口卡的配置信息,如IP地址、子网掩码和默认网关。通过选项,IPConfig还可用于刷新DNS解析缓存、重置TCP/IP堆栈等高级操作。 4. Netsh工具的使用:Netsh是一个功能强大的命令行脚本工具,它允许用户显示或修改网络配置。Netsh提供了一种方法,用来通过脚本查看和修改网络接口卡、DNS、DHCP和路由配置。 5. 多网卡环境下的网络配置:在有多块网卡的机器上,管理员需要能够管理和配置每块网卡的网络设置。这可能包括更改IP地址、设置网络优先级、启用和禁用网卡等操作。 6. 自动化网络配置:自动化网络配置可以显著提升网络管理效率,尤其是在有大量客户端需要维护的情况下。批处理文件通过执行一系列预定义命令来实现这一目的。 7. TCP/IP协议:TCP/IP是互联网上使用的标准协议族。它定义了计算机如何在各种网络中进行通信,如何处理数据包的封装、寻址、传输、路由以及如何在目的地的网络接口上重新组装。 8. Windows下TCP/IP的配置:理解并能够配置Windows系统中的TCP/IP协议是网络管理员日常工作的重要组成部分。它包括IP地址的分配、子网掩码的设置、默认网关和DNS服务器地址的配置等。 以上知识点涵盖了从批处理文件到网络配置的各个方面,并特别强调了在多网卡环境和TCP/IP协议下的应用。这些知识点对于系统管理员和对网络管理有兴趣的IT专业人士来说都十分重要。

相关推荐

filetype

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nginx配置文件 user zceo; worker_processes auto; error_log /data/openresty/logs/error.log; pid /apps/openresty/run/nginx.pid; events { worker_connections 10240; } http { server_tokens off; include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" | $http_accept | "$http_x_forwarded_for" | $host | ' '$request_time | $request_length | $upstream_addr | $upstream_status | $upstream_response_time | ' '$connection | $connection_requests '; access_log /data/openresty/logs/access.log main; sendfile on; tcp_nopush on; keepalive_timeout 65; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; #gzip_http_version 1.0; gzip_comp_level 3; gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript; gzip_vary on; gzip_disable "MSIE [1-6]\."; gzip_proxied any; # 指定服务器名称hash表的框大小 server_names_hash_bucket_size 512; # header头缓冲区大小,cookie内容较大时可加大 client_header_buffer_size 3072k; large_client_header_buffers 8 3072k; #设置允许发布内容为8M client_max_body_size 500M; client_body_buffer_size 3072k; # websocket配置 map $http_upgrade $connection_upgrade { default upgrade; '' close; } #获取真实请求IP map $http_x_forwarded_for $clientRealIp { "" $remote_addr; ~^(?P<firstAddr>[0-9\.]+),?.*$ $firstAddr; } map $http_user_agent $root_path { default /data/vue/bsp-workbenches-web; # 默认是 PC "~*Mobile" /data/vue/bsp-workbenches-h5; # 如果是移动设备,设置为 h5 路径 "~*Android" /data/vue/bsp-workbenches-h5; "~*iPhone" /data/vue/bsp-workbenches-h5; "~*iPad" /data/vue/bsp-workbenches-h5; "~*Windows Phone" /data/vue/bsp-workbenches-h5; } map $http_origin $cors_origin { default ""; ~^http?://(localhost|127\.0\.0\.1)(:\d+)?$ $http_origin; ~^https?://(.*\.)?gboss\.tech(?::\d+)?$ $http_origin; ~^https?://(.*\.)?ceboss\.cn(?::\d+)?$ $http_origin; ~^https?://(.*\.)?gmarketing\.cn(?::\d+)?$ $http_origin; } include vhosts/upstream.config; include vhosts/server.config; include vhosts/localhost.config; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vhosts/upstream.config内容 upstream tsdasdaweb { server xxx.xxx.xxx.xxx:8080; keepalive 2000; } upstream csadasdweb { server xxx.xx.xxx.xxx:80; keepalive 2000; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vhosts/server.config内容 多个下面类似配置 server { listen 80; server_name test-resource.gmarketing.tech; access_log /data/openresty/logs/access-test-resource.log main; error_log /data/openresty/logs/error-test-resource.log error; include /apps/openresty/nginx/conf/vhosts/test-resource-location.conf; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vhosts/localhost.config内容: server { listen 80; server_name 127.0.0.1; location /ssadas { stub_status on; } location ^~ /csasdasdweb/ { proxy_pass http://asdasdadweb; include /apps/openresty/nginx/conf/vhosts/common-proxy.conf; } } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test-resource-location.conf内容 location ^~ /file-api/ { proxy_pass http://file-api/; include /apps/openresty/nginx/conf/vhosts/common-x-form.conf; include /apps/openresty/nginx/conf/vhosts/common-proxy.conf; } location /file { include /apps/openresty/nginx/conf/vhosts/file-from.conf; alias /data/share/files/; } location /robots.txt { alias /data/vue/robots/robots.txt; add_header Content-Type text/plain; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /apps/openresty/nginx/conf/vhosts/common-x-form.conf内容 add_header Content-Security-Policy "frame-ancestors https://*.ceboss.cn https://*.gmarketing.tech https://*.gboss.tech;"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /apps/openresty/nginx/conf/vhosts/common-proxy.conf内容 proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 6000; proxy_read_timeout 6000; proxy_send_timeout 6000; proxy_buffer_size 3072k; proxy_buffers 16 3072k; proxy_busy_buffers_size 3072k; proxy_http_version 1.1; proxy_set_header Connection "Keep-Alive"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /apps/openresty/nginx/conf/vhosts/file-from.conf内容 # CORS 配置 if ($http_origin ~* (https?://([^/]+\.)?(gmarketing\.tech|gboss\.tech|ceboss\.cn)(:\d+)?$)) { set $cors "true"; } if ($http_origin ~* (http?://([^/]+\.)?(gmarketing\.tech|gboss\.tech|ceboss\.cn|localhost:5173|localhost|localhost:5177)(:\d+)?$)) { set $cors "true"; } # 处理 .tiff 文件的 CORS 头 location ~* \.tiff$ { if ($cors = "true") { add_header 'Access-Control-Allow-Origin' "$http_origin" always; add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; add_header 'Access-Control-Allow-Credentials' 'true' always; } try_files $uri =404; } # 核心 CORS 头 add_header 'Access-Control-Allow-Origin' "$http_origin" always; add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; add_header 'Access-Control-Allow-Credentials' 'true' always; # 预检请求处理 if ($request_method = 'OPTIONS') { add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 后端页面文件代码: public class SecureUrlGenerator { /** * ??? Nginx secure_link ????? URL. * * @param uri ????????? (??: "/images/secret/document.jpg") * @param secretKey ? Nginx ?????????? * @param durationInSeconds ???????(?) * @return ?????? URL (????) */ public static String generate(String uri, String secretKey, int durationInSeconds) { try { // 1. ??????? (Unix apoch time in seconds) long expires = System.currentTimeMillis() / 1000 + durationInSeconds; // 2. ????????? // ????? Nginx ? secure_link_md5 ?????????? // ??: "$secure_link_expires$uri secret_key" String stringToSign = expires + uri + " " + secretKey; // 3. ?? MD5 ?? MessageDigest md = MessageDigest.getInstance("MD5"); byte[] md5Bytes = md.digest(stringToSign.getBytes(StandardCharsets.UTF_8)); // 4. ? MD5 ???? URL ??? Base64 ?? // Nginx ? secure_link ????????: // - ?? '-' ?? '+' // - ?? '_' ?? '/' // - ????? padding '=' // Java 8 ? Base64.getUrlEncoder().withoutPadding() ?????????? String signature = Base64.getUrlEncoder().withoutPadding().encodeToString(md5Bytes); // 5. ????? URL // ??: /path/to/resource?md5=<signature>&expires=<timestamp> return String.format("%s?sign=%s&t=%d", uri, signature, expires); } catch (NoSuchAlgorithmException e) { // ??????,?????????????????? e.printStackTrace(); throw new RuntimeException("MD5 apoch_time is not available.", e); } } /** * ???,??????? */ public static void main(String[] args) { // --- ???? --- https://pre-file.gmarketing.tech/file/sm9pS0sF6oK/20250611/2b2e90fca62e41b4a048b424dfb75234.jpg String resourceUri = "24Gy8U0OlRbQ/20250616/04fa62de6149b4d11e79fce3ac7638b4.jpg"; String mySecretKey = "q8xyMiuJJAomkrk"; // ????????,??Nginx???? int validDuration = 43200; // ?????12?? (43200?) // --- ???? URL --- String signedUrl = generate(resourceUri, mySecretKey, validDuration); // --- ???? --- System.out.println("?? URI: " + resourceUri); System.out.println("????? URL: " + signedUrl); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 请结合提供内容,修改nginx配置完成如下需求 测试环境Nginx 新的文件服务https://test-resource.gmarketing.tech 只允许通过含有码(sm9pS0sF6oK|24Gy8U0OlRbQ)的链接,并且需要对Referer进行验证,只允许通过含有以下Referer的链接访问【test-wb.gboss.tech test-console.gmarketing.tech test-sw.ceboss.cn】 测试环境Nginx 新的文件服务https://test-resource.gmarketing.tech 需要对sign和时间戳进行校验,加密Key是(q8xyMiuJJAomkrk 请勿泄露),加密方式见截图,加密后的链接示例(https://test-resource.gmarketing.tech/file/24Gy8U0OlRbQ/20250616/04fa62de6149b4d11e79fce3ac7638b4.jpg?sign=ei6aaK9I3H-9ph88m4mrpQ&t=1750103291)

filetype

from scapy.all import * import subprocess import datetime import pickle import config import sched, time ##正常端口 allow_ports = config.allow_ports ##白名单ip allow_ip=config.allow_ip local_ip=config.local_ip ip_map={} import threading # 定义一个线程函数 def task(): while True: need_del_map=[] for ip in ip_map: diff=datetime.datetime.now()-ip_map[ip] seconds=diff.total_seconds() if seconds >600: remove_firewall(ip) if ip in ip_map: need_del_map.append(ip) for key in need_del_map: ip_map.pop(key) with open("data.pickle", "wb") as outfile: pickle.dump(ip_map, outfile) time.sleep(5) # 创建一个新线程 t = threading.Thread(target=task) # 启动线程 t.start() if os.path.exists("data.pickle"): try: with open("data.pickle", "rb") as infile: ip_map = pickle.load(infile) except Exception: print(" load hisfile error") print(ip_map) def packet_callback(packet): if packet.haslayer(TCP): if packet[TCP].flags == 'S': try: src_ip = packet[IP].src dst_ip = packet[IP].dst if dst_ip != local_ip: return dst_port = packet[TCP].dport if not src_ip in allow_ip: if str(dst_port) in allow_ports: print("ip:"+src_ip+",allow visit port:",dst_port) return else: if src_ip in ip_map: ip_map[src_ip]=datetime.datetime.now() return add_firewall(src_ip) with open("addfilewall.log", "a") as outfile: outfile.write(str(packet)+"\n") except Exception as e: print("error",e) lock = threading.Lock() def add_firewall(ip): lock.acquire() src_ip=ip command = f"netsh advfirewall firewall show rule name=\"{src_ip}\"" output = subprocess.run(command, capture_output=True, text=True) if "没有与指定标准相匹配的规则。" in output.stdout: command = "netsh advfirewall firewall add rule name="+src_ip+" dir=in action=block remoteip="+src_ip subprocess.run(command, capture_output=True, text=True, check=False) ip_map[src_ip]=datetime.datetime.now() print("ban ip"+src_ip) else: ip_map[src_ip]=datetime.datetime.now() print(" exit rule name:"+src_ip) with open("data.pickle", "wb") as outfile: pickle.dump(ip_map, outfile) lock.release() def remove_firewall(ip): lock.acquire() command = "netsh advfirewall firewall delete rule name="+ip subprocess.run(command, capture_output=True, text=True, check=False) print("清除禁用规则:"+ip) lock.release() sniff(filter="tcp", prn=packet_callback) 是什么作用,运行久了内存会增加,请给出建议并提供修改后的代码

filetype

C:\Users\16079>wsl.exe -d Ubuntu-24.04 hkw@localhost:/mnt/c/Users/16079$ nano ~/.bashrc hkw@localhost:/mnt/c/Users/16079$ ollama serve Error: listen tcp 172.18.0.2:11434: bind: cannot assign requested address hkw@localhost:/mnt/c/Users/16079$ nano ~/.bashrc hkw@localhost:/mnt/c/Users/16079$ nano ~/.bashrc hkw@localhost:/mnt/c/Users/16079$ ollama serve Error: listen tcp 172.18.0.2:11434: bind: cannot assign requested address hkw@localhost:/mnt/c/Users/16079$ export OLLAMA_HOST=0.0.0.0:11434 ollama serve 2025/03/13 19:55:18 routes.go:1125: INFO server config env="map[CUDA_VISIBLE_DEVICES: GPU_DEVICE_ORDINAL: HIP_VISIBLE_DEVICES: HSA_OVERRIDE_GFX_VERSION: OLLAMA_DEBUG:false OLLAMA_FLASH_ATTENTION:false OLLAMA_HOST:http://0.0.0.0:11434 OLLAMA_INTEL_GPU:false OLLAMA_KEEP_ALIVE:5m0s OLLAMA_LLM_LIBRARY: OLLAMA_MAX_LOADED_MODELS:0 OLLAMA_MAX_QUEUE:512 OLLAMA_MODELS:/home/hkw/.ollama/models OLLAMA_NOHISTORY:false OLLAMA_NOPRUNE:false OLLAMA_NUM_PARALLEL:0 OLLAMA_ORIGINS:[http://localhost https://localhost http://localhost:* https://localhost:* http://127.0.0.1 https://127.0.0.1 http://127.0.0.1:* https://127.0.0.1:* http://0.0.0.0 https://0.0.0.0 http://0.0.0.0:* https://0.0.0.0:* app://* file://* tauri://*] OLLAMA_RUNNERS_DIR: OLLAMA_SCHED_SPREAD:false OLLAMA_TMPDIR: ROCR_VISIBLE_DEVICES:]" time=2025-03-13T19:55:18.170+08:00 level=INFO source=images.go:753 msg="total blobs: 5" time=2025-03-13T19:55:18.171+08:00 level=INFO source=images.go:760 msg="total unused blobs removed: 0" time=2025-03-13T19:55:18.171+08:00 level=INFO source=routes.go:1172 msg="Listening on [::]:11434 (version 0.3.9)" time=2025-03-13T19:55:18.176+08:00 level=INFO source=payload.go:30 msg="extracting embedded files" dir=/tmp/ollama724607946/runners time=2025-03-13T19:55:24.162+08:00 level=INFO source=payload.go:44 msg="Dynamic LLM libraries [cpu cpu_avx cpu_avx2 cuda_v11 cuda_v12 rocm_v60102]" time=2025-03-13T19:55:24.162+08:00 level=INFO source=gpu.go:200 msg="looking for compatible GPUs" time=2025-03-

摇滚死兔子
  • 粉丝: 72
上传资源 快速赚钱