How to make eth0 and ppp0 co-exist

Walter Dnes waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org
Sun Jul 20 22:59:42 UTC 2008


  Today's problem... you have a machine that is part of a LAN.  It also
has a dialup modem.  You want to be able to dial up and fetch email, or
do some websurfing, and then log off, all without disrupting your LAN
connection.  Maybe you even want to dialup from machine A and download a
file from the net directly to a remote directory (NFS or SAMBA) that is
mounted on machine B.  Yes folks, it can be done.  Here is how I do it...

  - My little LAN is 192.168.123.248 netmask 255.255.255.248, which can
    also be written as 192.168.123.248/29 (YES!)

  - The gateway address (i.e. the router) is 192.168.123.254  Your LAN
    and gateway will probably be different.  Change to match your system.

  - In Gentoo, eth0 and its routes are defined in /etc/conf.d/net  Your
    distro may use different files and/or syntax.  Change as appropriate
    for your system.  Note the 2 routes...

config_eth0="192.168.123.250 broadcast 192.168.123.255 netmask
255.255.255.248 mtu 1452"
routes_eth0=(
"default via 192.168.123.254 metric 2"
"192.168.123.248/29 via 192.168.123.254 metric 0"
)

  Where more than 1 route can get you to a destination, the "tiebreaker"
is the lowest ("least expensive") metric.  The default route (if no
other way is available) is via my ADSL router (192.168.123.254).  It has
metric 2.  Packets destined for my little LAN go via the higher priority
(metric 0) route.  Here's ifconfig (minus the lo info) and "route -n"
output...


[d530][root][~] ifconfig
eth0 Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
     inet addr:192.168.123.250  Bcast:192.168.123.255 Mask:255.255.255.248
     UP BROADCAST RUNNING MULTICAST  MTU:1452 Metric:1
     RX packets:1069331 errors:0 dropped:0 overruns:0 frame:0
     TX packets:1420677 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:100
     RX bytes:461720479 (440.3 Mb)  TX bytes:1652832534 (1576.2 Mb)
     Memory:fdfc0000-fdfe0000

[d530][root][~] route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use
Iface
192.168.123.248 192.168.123.254 255.255.255.248 UG    0      0        0 eth0
192.168.123.248 0.0.0.0         255.255.255.248 U     0      0        0 eth0
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
0.0.0.0         192.168.123.254 0.0.0.0         UG    2      0        0 eth0

  When I dialup, the interface and route situation changes as follows...


[d530][root][~] ifconfig
eth0 Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
     inet addr:192.168.123.250  Bcast:192.168.123.255 Mask:255.255.255.248
     UP BROADCAST RUNNING MULTICAST  MTU:1452 Metric:1
     RX packets:1071006 errors:0 dropped:0 overruns:0 frame:0
     TX packets:1422095 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:100
     RX bytes:463287074 (441.8 Mb)  TX bytes:1653016628 (1576.4 Mb)
     Memory:fdfc0000-fdfe0000

ppp0 Link encap:Point-to-Point Protocol
     inet addr:208.72.122.229  P-t-P:208.72.120.40 Mask:255.255.255.255
     UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
     RX packets:23 errors:0 dropped:0 overruns:0 frame:0
     TX packets:43 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:3
     RX bytes:19137 (18.6 Kb)  TX bytes:5291 (5.1 Kb)

[d530][root][~] route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
208.72.120.40   0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
192.168.123.248 192.168.123.254 255.255.255.248 UG    0      0        0 eth0
192.168.123.248 0.0.0.0         255.255.255.248 U     0      0        0 eth0
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
0.0.0.0         208.72.120.40   0.0.0.0         UG    0      0        0 ppp0
0.0.0.0         192.168.123.254 0.0.0.0         UG    2      0        0 eth0

  The route associated with ppp0 has priority over all other routes,
except the one to my little LAN.  So my computer can talk to the LAN and
to the internet simultaneously.  When I disconnect the dialup session,
things go back to their previous state.

-- 
Walter Dnes <waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org>
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list