命名 PPP 接口

Cal*_*umA 5 linux networking ubuntu ppp network-interface

我有两个 PPP 对等点,dsl-line1 和 dsl-line2,它们在 Ubuntu(服务器)Linux 上配置了 pppd。

它们由 /etc/network/interfaces 文件和 auto thingy 启动,但是每个 PPP 连接选择名称 pppX,其中 X 取决于哪个首先出现。

我想让 dsl-line1 提供一个名称,例如“dsl0”,而 dsl-line2 的名称类似于“dsl1”,以便我可以更轻松地为每个规则创建防火墙规则并设置路由(以及因为更容易配置)。

我的问题是如何让 pppd 的接口自行命名?

/etc/ppp/peers/dsl-line1(dsl-line2除了去掉默认路由和以太网接口不同外,基本相同)

noipdefault
defaultroute
replacedefaultroute
hide-password
#lcp-echo-interval 30
#lcp-echo-failure 4
lcp-echo-interval 10
lcp-echo-failure 3
noauth
persist
#mtu 1492
#persist
#maxfail 0
#holdoff 20
plugin rp-pppoe.so eth1
user "xxxx@xxxx.xxx"
Run Code Online (Sandbox Code Playgroud)

/etc/network/interfaces(line1 部分​​,同样,2 非常相似)

auto dsl0
iface dsl0 inet ppp
    pre-up /sbin/ifconfig eth1 up # line maintained by pppoeconf
    post-up /bin/sh /home/callum/ppp0_up.sh # Route everything
    post-up /bin/sh /etc/miniupnpd/ppp0_up.sh # Start miniupnpd (if not alr$
    provider dsl-line1
Run Code Online (Sandbox Code Playgroud)

提前致谢。

Dan*_*Dan 8

虽然旧版本pppd提供了unit@CallumA指出的选项:

   unit num
          Sets the ppp unit number (for a ppp0 or ppp1 etc interface
          name) for outbound connections.
Run Code Online (Sandbox Code Playgroud)

... 更新的pppdfor Linux版本(例如 2.4.7)已修补以提供该ifname选项,该选项允许您设置完全任意的接口名称,例如ppp_tunnelormagic0等:

   ifname string
          Set the ppp interface name for outbound connections.
          If the interface name is already in use, or if the name 
          cannot be used for any other reason, pppd will terminate.
Run Code Online (Sandbox Code Playgroud)

正如评论中指出的那样,该ifname选项是Linux-specific。我的猜测是它没有合并到上游,因为并非所有操作系统都能够设置任意接口名称。(在 Linux 上,接口名称使用SIOCSLIFNAME ioctl.)


Cal*_*umA 3

我发现最好的选择是 /etc/ppp/peers/... 文件中的“unit”选项。该选项是一个整数,它命名接口 pppX,其中 X 是“unit”后面的 int。

我最终只是在 /etc/network/interfaces 中命名接口 pppX 并在对等文件中使用“unit”以确保它们以这种方式命名。