Skip to contentSkip to conversation

How are tunneled interfaces masqueraded?

DISCUSSION Glen Huang 2 participants 2 messages Jul 1, 2015 – Jul 2, 2015

lore
Share & tools
lore

Glen Huang

author
#0 lore raw

Hi,

I'm having difficulty wrapping my head around the concept of masquerading a tunneled interface. I'd be grateful if someone could shed some light on it.

First, just to make sure I understand the masquerade target right. If I masquerade a pppoe interface that connects a host to its ISP, and although ethernet frames encapsulating ppp frames travel through this interface, netfilter digs into the ppp frames and translate the encapsulated IP packets. Is this correct?

If so, what about the case where the ppp interface is tunneled? Let's take pptp for an example. If a ppp interface is created with pppd, then tunneled through GRE by pptpd, and i masquerade that ppp interface, as outbound packets travel through it, what packets are translated? The ones that travels in the virtual ppp interface or the ones that is generated by pptpd and get sent to the outside world?

Thank you very much.

#1 lore raw
Quoted 3 lines · Glen Huang

Hi,

If I masquerade a pppoe interface that connects a host to its ISP,

Which interface exactly ?
There are two network interfaces involved in a PPPoE connection : the ethernet interface (eth?) transmitting and receiving the encapsulating PPPoE frames and the PPP interface (ppp?) transmitting and receiving the encapsulated IP packets (or any other network protocol negotiated with a NCP) of the PPP session.

Quoted 3 lines

and although ethernet frames encapsulating ppp frames travel through this interface, netfilter digs into the ppp frames and translate the encapsulated IP packets. Is this correct?

If you masquerade packets going out the PPP interface ppp?, netfilter doesn not have to dig into anything : the packets are plain IP packets, so they are passed to iptables.

If you masquerade packets going out the ethernet interface eth?, the packets are PPPoE frames, not IP packets, so netfilter will usually not see them. The exception is if the ethernet interface is part of a bridge, CONFIG_BRIDGE_NETFILTER is enabled in the kernel and the sysctls net.bridge.bridge-nf-filter-pppoe-tagged and net.bridge.bridge-nf-call-iptables are enabled. Then netfilter digs into the PPPoE frames and passes the encapsulated IP packets to iptables. Besides, I suspect that if the PPPoE frames are locally generated (i.e. not bridged), the encapsulated IP packets have already been seen by iptables POSTROUTING chain at the IP layer and had the opportunity to be masqueraded, so another IP masquerading at the bridge layer is not possible.

Quoted 6 lines

If so, what about the case where the ppp interface is tunneled? Let's take pptp for an example. If a ppp interface is created with pppd, then tunneled through GRE by pptpd, and i masquerade that ppp interface, as outbound packets travel through it, what packets are translated? The ones that travels in the virtual ppp interface or the ones that is generated by pptpd and get sent to the outside world?

The ones that travel through the PPP interface of course.