Linux 如何找到PPP接口的默认网关?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8178093/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 02:21:23  来源:igfitidea点击:

How to find the default gateway of PPP interface?

linuxppp

提问by Ravi

I am using Debian Linux and using wvdial, I am able to establish ppp connection with the cellular network. ppp0 interface is getting created and IP address is assigned for the interface. How do I find out the default gateway for the PPP interface?

我正在使用 Debian Linux 并使用 wvdial,我能够与蜂窝网络建立 ppp 连接。正在创建 ppp0 接口并为该接口分配 IP 地址。如何找出 PPP 接口的默认网关?

采纳答案by David Schwartz

PPP is a point-to-point protocol. You are one point. The other point is the default route.

PPP 是一种点对点协议。你是一分。另一点是默认路由。

回答by lik

It might be helpful to check kernel IP routing table to find default gateway with:

检查内核 IP 路由表以查找默认网关可能会有所帮助:

netstat -rn

回答by saeed

default route of ppp connection has config in /etc/ppp/options.pptpd or /etc/

ppp 连接的默认路由在 /etc/ppp/options.pptpd 或 /etc/ 中有配置

回答by qzy

First of all, you can grab it from the interface info using ip (assuming your ppp interface is ppp0):

首先,您可以使用 ip 从接口信息中获取它(假设您的 ppp 接口是 ppp0):

/sbin/ip addr show ppp0 | grep peer | awk ' { print  } ' | sed 's/\/32//'

Second, when it's ppp, you can always choose "default device routing" over "default gw routing". In this case you could add the ppp0 device as your default device regardless of the gw address, using ip:

其次,当它是 ppp 时,您始终可以选择“默认设备路由”而不是“默认 gw 路由”。在这种情况下,无论 gw 地址如何,您都可以使用 ip 添加 ppp0 设备作为默认设备:

/sbin/ip route add default dev ppp0

HTH, Bálint

HTH, 巴林特