Hi Vasiu,
On 02/26/2018 03:18 PM, Vasiu Alexandru wrote:
Hi,
I have *2 PCs *with the following set-up:
- both have 2 interfaces: eth0 and eth1
*PC 1: *
* Not connected to network
* Has a *DHCP* Server with gives private IPs from 192.168.2.0/24
<
http://192.168.2.0/24>
* Is connected to *PC 2 *through eth0 (eth0 PC 1 to eth0 PC 2)
*PC 2:*
* eth0 has IP from *DHCP* Server from *PC 1*
* eth1 has IP from an intern network (also private, 10. ...)
If I run "ip route show" on PC 2, it shows *2 default gateways* (one for
eth0 and one for eth1) on *Ubuntu* and on a distribution with *connman*,
it shows just *one default gateway *(eth 1).
Questions:
1. Which is the normal behavior?
Obviously, having two default routes doesn't really make sense.
Basically, a default route means if any other routing rule doesn't match
take the default route. Though the kernel has some ways to differentiate
between two routing matching routing entries. There some metrics which
are used to decided which route it is to be used per frame. See [1] for
more information on this topic.
Although it is possible to have two default routes, it is rather
confusing and not intuitive from an user perspective. ConnMan clears the
routing table on startup. So any left overs from a previous setup or
ConnMan crash is removed first. Maybe you see a left over in the two
default route scenario.
2. If both interfaces have different IPs from the same network
there
should be only one default gateway or one for each interface (with
the same value)?
I would say there should only be one default route. In case you have
several different networks on the same computer (one or more interfaces)
you should have a routing entry per network.
For example I have connected via Ethernet and WiFi to my home network:
✗ ip r
default via 192.168.154.1 dev wlp2s0b1
192.168.154.0/24 dev wlp2s0b1 proto kernel scope link src 192.168.154.54
192.168.154.0/24 dev eth0 proto kernel scope link src 192.168.154.61
192.168.154.1 dev eth0 scope link
192.168.154.1 dev wlp2s0b1 scope link
So I have one default route which is over the WiFi interface and I have
a routing entry for each network per device.
Thanks,
Daniel
[1]
http://linux-ip.net/html/routing-selection.html