On Fri, Jun 09, 2017 at 10:36:45PM +0200, Christian Weisgerber wrote:
> The example in the pppoe(4) man page also includes
> 
>         !/sbin/route add default -ifp pppoe0 0.0.0.1
> 
> to specify the default route.  What happens to that?

Good question. It raises an interesting point: Setting a dest address is
still required to use a default route. Luckily, sppp(4) does not care
which address we use. All it cases about is a default route with a matching
ifindex. If it finds such a route, the destination address is updated.

So what happens is that you can now use *any* unique address as 'dest'.
The mechanism simply becomes more flexible.

For example, you could have two pppoe interfaces like this (note that -mpath
is needed in this case):

$ cat /etc/hostname.pppoe0
inet 0.0.0.0 255.255.255.255 NONE \
   pppoedev em0 authproto pap \
   authname 'testcaller' authkey 'donttell' up
dest 0.0.0.1
dynaddr dyndest
!/sbin/route -T1 add default -mpath -ifp pppoe0 0.0.0.1
$ cat /etc/hostname.pppoe1
inet 0.0.0.0 255.255.255.255 NONE \
   pppoedev em1 authproto pap \
   authname 'testcaller2' authkey 'donttell2' up
dest 0.0.0.2
dynaddr dyndest
!/sbin/route -T1 add default -mpath -ifp pppoe1 0.0.0.2

So your initial routing table looks like:

Destination        Gateway            Flags   Refs      Use   Mtu  Prio Iface
default            0.0.0.1            GSP        0        1     -     8 pppoe0
default            0.0.0.2            GSP        0        0     -     8 pppoe1
0.0.0.1            default            Hh         1        2     -     8 pppoe0
0.0.0.2            default            Hh         1        1     -     8 pppoe1
127.0.0.1          127.0.0.1          UHl        0        0 32768     1 lo0

And once the pppoe0 interface connects, sppp(4) modifies the appropriate
default route. It is marked UP and the new default gateway is entered:

Destination        Gateway            Flags   Refs      Use   Mtu  Prio Iface
default            100.148.133.201    UGSP       0       11     -     8 pppoe0
default            0.0.0.2            GSP        0        0     -     8 pppoe1
0.0.0.2            default            Hh         1        1     -     8 pppoe1
127.0.0.1          127.0.0.1          UHl        0        0 32768     1 lo0
212.60.251.248     212.60.251.248     UHl        0       16     -     1 pppoe0
213.148.133.201    212.60.251.248     UHh        1        1     -     8 pppoe0
#

These 0.0.0.x addresses are ugly, why not use regular private IPs instead?
This does the same thing:

$ cat /etc/hostname.pppoe0
inet 0.0.0.0 255.255.255.255 NONE \
   pppoedev em0 authproto pap \
   authname 'testcaller' authkey 'donttell' up
dest 192.168.42.1
dynaddr dyndest
!/sbin/route -T1 add default -mpath -ifp pppoe0 192.168.42.1
$ cat /etc/hostname.pppoe1
inet 0.0.0.0 255.255.255.255 NONE \
   pppoedev em1 authproto pap \
   authname 'testcaller2' authkey 'donttell2' up
dest 10.42.42.1
dynaddr dyndest
!/sbin/route -T1 add default -mpath -ifp pppoe1 10.42.42.1

Destination        Gateway            Flags   Refs      Use   Mtu  Prio Iface
default            192.168.42.1       GSP        0        0     -     8 pppoe0
default            10.42.42.1         GSP        0        0     -     8 pppoe1
10.42.42.1         default            Hh         1        1     -     8 pppoe1
192.168.42.1       default            Hh         1        1     -     8 pppoe0
127.0.0.1          127.0.0.1          UHl        0        0 32768     1 lo0

After connecting:

Destination        Gateway            Flags   Refs      Use   Mtu  Prio Iface
default            100.148.133.201    GSP        0        0     -     8 pppoe0
default            10.42.42.1         GSP        0        0     -     8 pppoe1
10.42.42.1         default            Hh         1        1     -     8 pppoe1
192.168.42.1       default            Hh         1        1     -     8 pppoe0
127.0.0.1          127.0.0.1          UHl        0        0 32768     1 lo0

Reply via email to