netdev icon indicating copy to clipboard operation
netdev copied to clipboard

Unexpected behaviour when no gateway is set

Open marcbrevoort-cyberhive opened this issue 3 years ago • 0 comments

Tested on (raspbian) Linux.

Steps to reproduce:

  • Have a pi running on 192.168.1.101. In this case, file /etc/dhcpcd.conf (note this ends with cd.conf) contains a section,
interface wlan0
static ip_address=192.168.1.101
static routers=192.168.1.1
static domain_name_servers=8.8.8.8
static domain_search=

interface eth0
static ip_address=192.168.1.101
static routers=192.168.1.1
static domain_name_servers=8.8.8.8
static domain_search=
  • compile and run the example code This gives the following output, as expected:
Default Interface
	Index: 2
	Name: eth0
	Friendly Name: None
	Description: None
	Type: Ethernet
	MAC: e2:5f:21:41:11:b2
	IPv4: [Ipv4Net { addr: 192.168.1.101, prefix_len: 24, netmask: 255.255.255.0 }]
	IPv6: [Ipv6Net { addr: fe80::217f:fa11:4a86:38fa, prefix_len: 64, netmask: ffff:ffff:ffff:ffff:: }]
	Flags: 69699
	Transmit Speed: Some(1000000000)
	Receive Speed: Some(1000000000)
Default Gateway
	MAC: 8c:59:73:65:ba:d8
	IP: 192.168.1.1
  • Now we edit the above section to read,
interface eth0
static ip_address=192.168.1.101
static routers=
static domain_name_servers=
static domain_search=

(the wlan interface is removed altogether). We then reboot the pi. The above is intended to create an air-gapped network environment.

Running the code again results in

Default Interface
	Index: 7
	Name: vethc3d719f
	Friendly Name: None
	Description: None
	Type: Ethernet
	MAC: 56:12:1f:7d:6f:98
	IPv4: [Ipv4Net { addr: 169.254.125.86, prefix_len: 16, netmask: 255.255.0.0 }]
	IPv6: [Ipv6Net { addr: fe80::e330:9b42:1990:d81a, prefix_len: 64, netmask: ffff:ffff:ffff:ffff:: }]
	Flags: 69699
	Transmit Speed: Some(10000000000)
	Receive Speed: Some(10000000000)
Default Gateway: (Not found)

While the transmit/receive speed of this interface is reportedly higher than eth0/wlan0, it's a virtual device (pointing to master br-ef67...49):

5: br-ef6764190849: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:32:16:c3:bd:6b brd ff:ff:ff:ff:ff:ff
    inet 172.19.0.1/16 brd 172.19.255.255 scope global br-ef6764190849
       valid_lft forever preferred_lft forever
    inet6 fe80::42:c6ff:fec3:ad6b/64 scope link 
       valid_lft forever preferred_lft forever
7: veth06ee6be@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-ef6764190849 state UP group default 
    link/ether 5e:b1:24:aa:38:cf brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 169.254.243.193/16 brd 169.254.255.255 scope global noprefixroute veth06ee6be
       valid_lft forever preferred_lft forever
    inet6 fe80::5cb1:14ff:fea8:f8cf/64 scope link 
       valid_lft forever preferred_lft forever

In the pi's GUI I have disabled all interfaces but eth0. /etc/interfaces points to /etc/itnerfaces.d/ which is empty. On login I get

Wi-Fi is currently blocked by rfkill.
Use raspi-config to set the country before use.

showing that the wlan interface has been switched off.

The actual hardware devices eth0, having been assigned 192.168.1.101, is still available for LAN traffic, however. What could be the reason it is not chosen as default once the gateway has been removed?

marcbrevoort-cyberhive avatar Jul 06 '22 15:07 marcbrevoort-cyberhive