Linux – Using eth0 and ppp interfaces in an interchangeable mode

debianethernetlinuxnetworking

I've a Debian system without a UI, with a GPRS modem attached to it. Now, this system is connected with Ethernet through a standard cable.

I want to obtain a configuration that allows the computer to access the Internet via Ethernet if an Ethernet cable is connected, otherwise use the GPRS to do so. Practically speaking, I want the eth0 interface to be the preferable interface if it is on, and ppp (only) if the former isn't mounted.

How do I obtain an easy /etc/network/interfaces configuration to achieve this?

Best Answer

There are if-up.d and if-down.d directories in /etc/ppp/. You should put ifup and ifdown scripts there to configure your default gateway.