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

Implementing PPPoE half-bridge/ip-passthrough to suit IPSec VPN firewall appliance with Linux

· 52CE 我爱测

(I'm editing my own question and posting an answer for anyone else who finds themselves in a similar position.) I would like a firewall appliance that requires a public static IP on its external interface to be used with an ISP-a…

问题原文

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

(I'm editing my own question and posting an answer for anyone else who finds themselves in a similar position.)

I would like a firewall appliance that requires a public static IP on its external interface to be used with an ISP-approved ADSL modem. (This setup isn't recommended as the ADSL service and modem are consumer-grade, but we need to save money.)

The modem can act as a router, which means it will NAT all traffic and use the service's 1 public static IP on its external interface. We can't use a public subnet behind this NAT as this isn't supported by this ADSL service.

The other option is that this modem can act as a full bridge, but the firewall appliance is not capable of terminating a PPP link.

There is one modem (DrayTek Vigor 120) that I could acquire that is capable of half-bridge mode (DrayTek calls this "True-DMZ"), where one device behind the modem is assigned the ADSL link's one public static IP address. This worked, but unfortunately we had unrelated problems with the ADSL line and were not able to receive any support from our ISP while using this modem.

How do I configure a Linux PC so that it terminates the PPP link in half-bridge mode?

已采纳解答

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

I used Debian on a PC with three NICs (1 for management, 1 to connect to the modem, 1 to connect to the firewall). I ended up with eth0=management, eth1=modem, eth2=firewall, ppp0=ADSL service and lo.

  1. Prepare PC with ppp (and pppoeconf if desired) [note: this PC will lose its connection to the internet when this is all set up]
  2. Put modem into full-bridge mode
  3. Configure ppp and connect, test connection, etc.
  4. Configure eth1 and eth2 as "auto ethx" and "iface ethx" in /etc/network/interfaces
  5. Add the following to /etc/ppp/ip-up (just before the "run-parts" line):

    ifconfig ppp0 an IP in a subnet you'll never use/that subnet's CIDR

    ifconfig eth2 up

    ifconfig eth2 your public IP/your public subnet

    ip route delete default

    ip route add default dev ppp0

    ip route flush cache

You should end up with a route table that looks like this:

  • 0.0.0.0/0 ppp0
  • your public IP's network/your public IP's subnet eth2
  • network you don't care about/subnet ppp0

The way this works:

  • eth1 doesn't need an IP address, as PPPoE is a frame protocol
  • eth2 gets another IP in the same subnet as your public IP
  • ppp0 gets an IP you don't care about (but doesn't clash with anything you do care about)
  • when a packet arrives from ADSL, its source will be some other public IP and its destination will be your public IP: it will egress eth2 (due to route #2)
  • when a packet arrives from the firewall, its source will be your public IP and its destination will be some other public IP: it will egress ppp0 (due to default route)

Example:

Say your public IP is 1.1.1.100/24 and your gateway is 1.1.1.1 (our ISP assigned us something like this; the way I understand it, you would normally get 1.1.1.100/32 with no gateway). Say also that 172.16.1.0/24 is a network you'll never use anywhere. So:

ifconfig ppp0 172.16.1.1/24

ifconfig eth2 up

ifconfig eth2 1.1.1.101/24

ip route delete default

ip route add default dev ppp0

ip route flush cache

Your route table:

  • 0.0.0.0/0 ppp0
  • 1.1.1.0/24 eth2
  • 172.16.1.0/24 ppp0

Note that you are assigning eth2 1.1.1.101 and not 1.1.1.100. Eth2 needs to be on the same subnet as your public IP, but not the public IP itself.

Caveat:

You'll need to use either the real subnet used by your ISP (e.g., 1.1.1.0/24) or make up a pretend one (and use /30 to keep it as small as possible). Other IPs (typically other customers of your ISP) in this subnet on the internet will become unreachable to you.

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

资料来源与适用范围

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

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

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