Q:

Can I prevent a default route being added when bringing up an interface? 

I have a system with two NICs on it.   This machine, and a few accompanying devices will be moved and attached to different LANs or sometimes it'll be using dial-up. 
    eth0:
    - 10.x.x.x address space
    - no internet gateway
    - only a few devices

eth1 (when used):
- 172.16.x.x or 192.168.x.x or other address spaces
- access to the gateway from LAN to internet

ppp0 (when used):
- internet access through dialup using KPPP

I'm using ifconfig to bring interfaces up or down (other than with ppp0, which is handled by KPPP). 
If I bring up eth1 first, it gets an address from its DHCP and gets the gateway and that is added to routing so there's no trouble reaching the LAN and the internet. 
If I bring up eth0 first or second, it gets its address and sets the default gateway to within its address space (in the 10.x.x.x range).   If I bring up eth0 first and eth1 second, the default gateway is still kept to within the 10.x.x.x range. 
So no matter what I do, eth0 will override eth1 and "claim" the gateway in the routing. 
Is there some way to either prevent eth0 from claiming the gateway, or to make sure eth1 (if brought up 2nd) uses its gateway?   Or can I somehow prioritize a ranking of which interface's gateway should be used over the others? 
I basically want to make sure eth1's default address space gateway is used if it's active, and if not, then the ppp0's default gateway is used.   I'd like to be able to prevent eth0 from ever having the default gateway. 

A:

I faced similar problem on Raspbian (I suppose the solution below will be applicable to Debian as well).  Raspberry Pi 3 has 2 NICs integrated: Wi-Fi and Ethernet.  I use both of them, they are wlan0 and eth0, respectively.  wlan0 is connected to my home Wi-Fi network and internet access comes through this interface.  It gets its settings via DHCP from my home router.  eth0 is connected directly to my windows PC and has static IP assigned.  No internet access via eth0 was available since I didn't configure it on my windows PC. 
In Raspbian, the dhcpcd daemon is responsible for configuring network interfaces.  In order to set static IP to eth0 interface, there were following lines added to the end of /etc/dhcpcd.conf:
interface eth0

static ip_address=192.168.2.2/24
static routers=192.168.2.1
static domain_name_servers=192.168.2.1

With this settings, dhcpcd created 2 default routes and route via eth0 had higher priority than that via wlan0:
pi@raspberrypi:~ $ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.2.1     0.0.0.0         UG    202    0        0 eth0
default         192.168.1.254   0.0.0.0         UG    303    0        0 wlan0
192.168.1.0     *               255.255.255.0   U     303    0        0 wlan0
192.168.2.0     *               255.255.255.0   U     202    0        0 eth0

So I had no internet access, because system tried to route it via eth0 and it didn't have internet access, as I mentioned above. 
To solve the problem, I used nogateway option in the /etc/dhcpcd.conf for eth0 interface.  So eth0-specific configuration started looking like that:
interface eth0

static ip_address=192.168.2.2/24
static routers=192.168.2.1
static domain_name_servers=192.168.2.1
nogateway

After saving this configuration and rebooting, there were no default route via eth0:
pi@raspberrypi:~ $ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.254   0.0.0.0         UG    303    0        0 wlan0
192.168.1.0     *               255.255.255.0   U     303    0        0 wlan0
192.168.2.0     *               255.255.255.0   U     202    0        0 eth0

Internet access appeared, and the problem was solved. 

A:

On RHEL6/Fedora 22 the following has been tested.  
In /etc/sysconfig/network-scripts/ifcfg-eth1 
add the line:
DEFROUTE=no

Replace eth1 with name of interface where default routing is not wanted. 
This can also be done via Network Manager GUI by checking the box "Use this connection only for resources on its network" at the bottom of the IPv4 tab.  
DEFROUTE=no prevents the addition of the default route ( destination 0.0.0.0 ) to the routing table when the interface is enabled.  ie.  the following entry would not be added.  
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         172.16.x.x      0.0.0.0         UG        0 0          0 eth1

A:

The DHCP server configuration is wrong.  It must not send a default gateway option when it can't provide routing to the rest of the world.  If it does send that option then any client may assume that it can send packets for any off-link destination to the specified default gateway. 
So your box is right in using the default gateway from eth0 if it is told so by DHCP.  The solution is to remove the bad option from your DHCP server.