惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
L
LangChain Blog
Blog — PlanetScale
Blog — PlanetScale
阮一峰的网络日志
阮一峰的网络日志
Microsoft Azure Blog
Microsoft Azure Blog
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog
Y
Y Combinator Blog
D
DataBreaches.Net
Engineering at Meta
Engineering at Meta
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements

sjdhome

不要每次都与 AI 从零开始 · sjdhome AI Coding 时代,编程语言仍然重要 · sjdhome 借鉴 Herdr,让 Claude 从头到尾写出一个 tmux AI Agent 监控器 · sjdhome 当 AI 越来越像你,你也在越来越像 AI · sjdhome LLM 与信息熵 · sjdhome sjdhome.com 2025 年度总结 | sjdhome 2025 年度总结 · sjdhome 我的 2024 年 | sjdhome 我的 2024 年 | sjdhome 我的 2024 年 · sjdhome sjdhome.com 制度与利益 | sjdhome 制度与利益 · sjdhome 解决 Windows PPPoE 连接在系统睡眠后消失 | sjdhome 解决 Windows PPPoE 连接在系统睡眠后消失 | sjdhome 解决 Windows PPPoE 连接在系统睡眠后消失 · sjdhome 解决 Next.js build 完成后卡住的问题 | sjdhome 解决 Next.js build 完成后卡住的问题 | sjdhome 解决 Next.js build 完成后卡住的问题 · sjdhome 实现 WSL 2 开机免登录自动启动 | sjdhome 实现 WSL 2 开机免登录自动启动 | sjdhome 实现 WSL 2 开机免登录自动启动 · sjdhome 我的 2023 年 | sjdhome 我的 2023 年 | sjdhome 我的 2023 年 · sjdhome 在 Windows 上启用 IP 转发 在 Windows 上启用 IP 转发 迁移到 Next.js | sjdhome 迁移到 Next.js | sjdhome
在 Windows 上启用 IP 转发 · sjdhome
https://sjdhome.com/about/ · 2023-11-10 · via sjdhome

在 Windows 上实现 net.ipv4.ip_forward 和 net.ipv6.conf.all.forwarding。

发布于更新于约 1 分钟

启用 IP 转发,可以让机器自身成为一台路由器来转发 IP 报文。在 Linux 下,可以通过 sysctl net.ipv4.ip_forward = 1sysctl net.ipv6.conf.all.forwarding = 1 来启用内核 IP 报文转发。但在 Windows 下,相关的文章却很稀少,许多带有误导性。

步骤

  1. 管理员权限运行 PowerShell,输入 Get-NetAdapter 确定要操作的网卡名称(即输出结果的 Name 列)。
  2. 输入Set-NetIPInterface -ifAlias '网卡名称' -Forwarding Enabled,单引号保留,网卡名称换成上面找到的。

要获取所有已打开转发功能的网卡,输入 Get-NetIPInterface -Forwarding Enabled

对比其他方法

  1. 使用netsh interface portproxy:只能实现端口对端口的转发,无法做到路由转发的效果,也不保留源 IP 地址。
  2. 修改注册表HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters:全局生效,无法单独针对某一块网卡做调整。

NAT (MASQUERADE)

Linux 下使用 IP 转发通常会搭配 iptables 的 MASQUERADE 功能使用。但在 Windows 下我没有找到对应功能。

如果你的需求是使用 WireGuard,将某台机器作为互联网出口,Tailscale 会更适合,他们解决了 NAT 问题。

参考资料