Why is there an interface field in routing table?

3

Imagine that we have an IP-packet, and we need to figure out which interface it should be sent through. There is an eth0 (for example) corresponding with our packet destination address.

But what if there is more than one data link layer protocol over eth0?

For example, Ethernet and PPPoE. How do we figure out which protocol the packet should be using?

Jofsey

Posted 2012-07-18T12:03:29.523

Reputation: 917

If you included routing table listing in your question you would probably answer it yourself. route print on windows, route on linux. – Art Shayderov – 2012-07-18T19:39:04.450

Answers

4

I don't think you can have more than one link layer on a single interface.

In the case of PPPoE, establishing the PPP connection creates another interface, typically called ppp0. Your routing table entry will point to ppp0, not to eth0. When a packet is routed to ppp0, it's actually handed to the local PPPoE software, not transmitted anywhere. But then the PPPoE software produces a new packet which it transmits via eth0.

This is similar to how some VPNs work, by the way. OpenVPN, for example, creates a new interface called either tun0 or tap0, whose "link layer" is the OpenVPN daemon. Send a packet to one of those, and the daemon encrypts it and puts the ciphertext into a new packet, typically plain UDP, addressed to the remote OpenVPN server. That packet goes through the routing process and finds its way to a real interface like eth0.

(Unlike the VPN example, when PPPoE sends a packet over eth0, it doesn't rely on the routing table to route the packet there, because eth0 is not configured with an IP address and packets can't be routed to it. Instead, I think it uses a raw socket to send a custom Ethernet frame, addressed to the PPPoE peer's MAC address, that contains a PPP payload, not an IP payload. RFC 2516 has the details of the protocol.)

Wyzard

Posted 2012-07-18T12:03:29.523

Reputation: 5 832

0

There is never more than a single data layer protocol operating over an interface (unless you are doing something very very strange). Where it looks like there might be, almost always some form of tunneling or encapsulation using is going on - there's usually some other virtual interface "riding on top of it".

"PPPoE" stands for PPP over Ethernet. THe physical interface eth0 is using Ethernet as the Layer 2 protocol. PPP is a layer on top of it, handled by a PPPoE daemon. So the PPP "link layer" packets are ultimately encapsulated in Ethernet frames.

Basically PPPoE works like tunneling/VPN software as @Wyzard says. Tunnels have a virtual interface on one "side", the de/encapsulation software in the middle, and then the real interface on the other side.

So you'll have an interface such as ppp0 or whatever, which is connected to the PPPoE daemon, and then the PPPoE daemon encapsulates what's coming in on ppp0 and shoves out of eth0. And vice versa.

One thing to keep in mind is that since Ethernet's MTU is 1500, but 8 bytes of room needs to be made for the PPPoE header, so the MTU of the PPPoE interface becomes 1492.

You don't need to touch eth0 directly since all you want coming out of eth0 is PPPoE packets for your DSL provider. It's the same general concept for VPNs or IPv6-over-IPv4 tunnels.

LawrenceC

Posted 2012-07-18T12:03:29.523

Reputation: 63 487