大网数据广告活动
服务器运维问答

How to find my VPN gateway?

· 52CE 我爱测

I'm not a network engineer but I'm trying to configure my linux machine to have internet access while being connected to my VPN. My current idea to solve this is to connect to my VPN while configuring my machine NOT to re-configu…

问题原文

原帖链接 · Muhammad Gelbana · CC BY-SA 3.0

I'm not a network engineer but I'm trying to configure my linux machine to have internet access while being connected to my VPN.

My current idea to solve this is to connect to my VPN while configuring my machine NOT to re-configure my routes after connecting to my VPN, then I would manually configure my machine's routes to access my VPN when I need to (i.e. for a specific IP range).

So I'm currently trying to understand the following routing table:

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     50     0        0 ppp0
0.0.0.0         192.168.16.1    0.0.0.0         UG    600    0        0 wlp8s0
10.100.0.0      0.0.0.0         255.255.255.255 UH    50     0        0 ppp0
62.135.17.146   192.168.16.1    255.255.255.255 UGH   0      0        0 wlp8s0
192.168.16.0    0.0.0.0         255.255.255.0   U     600    0        0 wlp8s0

How is it possible to have a 0.0.0.0 gateway for my VPN (ppp0) interface ?! Every possible information about my mentioned routing table is much appreciated. But in English please :D

已采纳解答

原帖链接 · zymhan · CC BY-SA 3.0

Your interface ppp0 is a Point-to-Point Protocol tunnel. PPP connections are designed to only go from one point to another, so there is no need for IP addressing. Essentially, if your machine sends a packet out over the PPP interface, there's only one place it can go! So no need to differentiate the possible recipients with different IP addresses.

You didn't specify which VPN software you're using, but configuring which routes are pushed to a client is a common option. If you're using OpenVPN, you can find information on defining which routes to push here.

EDIT: It seems like you may be using a PPTP VPN (which, by the way, is no longer sercure and should be avoided if possible). In that case, you can configure what routing entries are added by doing something like this:

Route traffic via ppp0

To route traffic via PPP0 interface, edit /etc/ppp/ip-up.d/route-traffic

vi /etc/ppp/ip-up.d/route-traffic

Append following sample code (modify NET an IFACE as per your requirments):

#!/bin/bash
NET="10.0.0.0/8" # set me
IFACE="ppp0" # set me
#IFACE=$1
route add -net ${NET} dev ${IFACE}

Save and close the file:

chmod +x /etc/ppp/ip-up.d/route-traffic

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-03-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。