单网卡Windows设备配置路由以同时访问互联网与私有网络的方法咨询
Hey there! Let's work through this issue together. Since you don't have permission to configure the private network gateway (172.16.28.1), we can fix this by adding static routes directly on your Windows machine. This will make sure traffic meant for your private network resources goes through the correct gateway, while all other internet traffic uses your default router (192.168.0.1).
Here's how to do it step by step:
1. Confirm the private network's subnet first
First, you need to know the exact subnet of the private network where your resources live. For example, if your private resources are in the range 172.16.28.0 to 172.16.28.255, the subnet is 172.16.28.0/24 (mask 255.255.255.0). If you're unsure, you can ping a known private resource and note its IP, or ask your network admin for the correct subnet range.
2. Open Command Prompt/PowerShell as Administrator
You need elevated privileges to modify system routes. Right-click the Start menu, select either Command Prompt (Admin) or Windows PowerShell (Admin).
3. Add the static route
Run this command (replace the subnet and mask with your actual private network details):
route add 172.16.28.0 mask 255.255.255.0 172.16.28.1 -p
- The
-pflag makes the route persistent—it will stay even after you restart your computer. Omit it if you only want the route to work temporarily. - If your private network uses a larger subnet (like
172.16.0.0/16), adjust the command to:route add 172.16.0.0 mask 255.255.0.0 172.16.28.1 -p
4. Verify the route works
- Run
route printin the admin command window. Look for the entry you just added under the "IPv4 Route Table" section to confirm it's there. - Test accessing both a private network resource (like your application) and a public website to make sure both work properly.
A few quick notes
- Make sure your Windows machine can already reach the private gateway
172.16.28.1(try pinging it first). If you can't, there might be a layer 2 connectivity issue between your machine's subnet and the private network that needs fixing first. - If you run into issues after adding the route, check if your Windows firewall is blocking traffic to the private subnet, or double-check that you used the correct subnet mask and gateway IP.
备注:内容来源于stack exchange,提问作者Hugh Mungus

