PC connection to beaglebone green - eth cable v usb cable

Hello All,

I can connect my PC to BBG with the eth cable or with usb cable. By default I have a connection with usb. To have a connection with eth cable I changed the /etc/network/interfaces file as follows:


This file describes the network interfaces available on your system

and how to activate them. For more information, see interfaces(5).

The loopback network interface

auto lo
iface lo inet loopback

The primary network interface

#auto eth0
#iface eth0 inet dhcp

Example to keep MAC address between reboots

#hwaddress ether DE:AD:BE:EF:CA:FE

auto eth0
iface eth0 inet static
address 192.168.7.10
netmask 255.255.255.0
gateway 192.168.7.1

iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.0
gateway 192.168.7.1

##connman: ethX static config
#connmanctl services
#Using the appropriate ethernet service, tell connman to setup a static IP address for that service:
#sudo connmanctl config --ipv4 manual <ip_addr> --nameservers <dns_server>

##connman: WiFi

#connmanctl
#connmanctl> tether wifi off
#connmanctl> enable wifi
#connmanctl> scan wifi
#connmanctl> services
#connmanctl> agent on
#connmanctl> connect wifi_*_managed_psk
#connmanctl> quit


My PC has IP 192.168.7.1
Including the lines begining with > I have eth cable connection to PC but I don’t have usb connection. To have usb connection I need to remove all lines starting with >.
It seams that somehow the eth cable connection has priority over the usb.
Is there a way of having both connections ( one at a time ) widthout having to alter the interfaces file ?

Thanks

on what device? you have specified 192.168.7.1 as the gateway on BOTH interfaces … does not compute.

PC is running what OS? your PC will show that 192.168.7.1 is on either the USB device OR the ETH device, but NOT BOTH. (likely the USB device)…

what IP does the ETH device show on the PC?

gomer

Hello,

My PC has Windows 7 / windows 10. The gateway is one I guess just to go. I am not testing ethernet connection outside but just PC to BBG. The ETH is x.x.x.10 and the usb0 is x.x.x.2 as is by default. Both addresses shown with ifconfig.
I don’t have the hardware now with me but I was testing the eth connection with a browser in one pc with windows 7 ( IP 192.168.7.1 ) and the usb0 connection with a pc with windows 10 ; this usb connection came by default with the BBG OS, and it works with the address 192.168.7.2 even if I remove the settings out of the ‘interfaces’ file. It means that at start up there must be a routine that configures this eth virtual connection but is seams that the eth connection using the ‘interfaces’ file bypasses this setup.

Thanks

I have no idea what this means.

I would need to know the details of the eth connection on the PC (which I asked for already).

If this is a work / corp setup, and you cannot or will not reveal these details, then ask your network administrator for assistance.

some networking ideas for you to research:

  • default route
  • subnet setup
  • packet forwarding (if you want to get to internet from BBG)

good luck
gomer

Hello gomer,

It means that at this point I don’t care about gateways. Perhaps you are missing the point on this subject. As soon as I get catch this issue again I will send you the info.

Thanks

@pluis

I would say to start with update your BB software. The fact that you mention conman leads be to believe you have very old software.

The latest OS uses systemd for networking.

This is configured in /etc/system/network/

by default it seems that a default route is not added when static IP’s are set.

Edit /etc/systemd/network/usb0.network and add the “Gateway=192.168.7.1” to the config as below.

[Match]
Name=usb0

[Link]
RequiredForOnline=no

[Network]
DHCP=no
Address=192.168.7.2/24
Gateway=192.168.7.1
DHCPServer=on

[DHCPServer]
EmitDNS=no
EmitRouter=no
EmitTimezone=no
MaxLeaseTimeSec=20min
PoolSize=1

By default eth0 will use DHCP, however you can also set this up as static.
edit /etc/system/network/eth0.network

[Match]
Name=eth0
Type=ether

[Link]
RequiredForOnline=yes

[Network]
DHCP=no
Address=192.168.7.5/24
Gateway=192.168.7.1

After making the changes you will either need to reboot, or perhaps just restarting the systemd network service will be enough.

If you have both plugged in you will get 2 routes to the gateway

root@BeagleBone:/etc/systemd/network# ip -br addr
lo               UNKNOWN        127.0.0.1/8 ::1/128 
eth0             UP             192.168.7.5/24 fe80::1eba:8cff:fea0:c598/64 
usb0             UP             192.168.7.2/24 fe80::1eba:8cff:fea0:c59b/64 
usb1             UP             192.168.6.2/24 fe80::1eba:8cff:fea0:c59d/64 
can0             DOWN           
can1             DOWN  

root@BeagleBone:/etc/systemd/network# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.7.1     0.0.0.0         UG    0      0        0 usb0
0.0.0.0         192.168.7.1     0.0.0.0         UG    0      0        0 eth0
192.168.6.0     0.0.0.0         255.255.255.0   U     0      0        0 usb1
192.168.7.0     0.0.0.0         255.255.255.0   U     0      0        0 usb0
192.168.7.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

Probably not an issue. You should in theory be able to set the metric value to give one route a preference, but last time I tried doing this had could not get it to work.

systemd networking has changed quite a bit and most posts on the internet are for older verisons and the syntax has changed over time.

Obviously you will need to set a static IP address on your windows computer. Also if pluging in directly, make sure your computers network interface can automatically switch rx/tx lines. If it is reasonably new it should. Failing that use a crossover cable.

Ok update to above for eth0.network and usb0.network files

root@BeagleBone:/etc/systemd/network# cat usb0.network 
[Match]
Name=usb0

[Link]
RequiredForOnline=no

[Network]
DHCP=no
Address=192.168.7.2/24
DHCPServer=on

[Route]
Gateway=192.168.7.1
Metric=100


[DHCPServer]
EmitDNS=no
EmitRouter=no
EmitTimezone=no
MaxLeaseTimeSec=20min
PoolSize=1

root@BeagleBone:/etc/systemd/network# cat eth0.network                                                                                                                       
[Match]
Name=eth0
Type=ether

[Link]
RequiredForOnline=yes

[Network]
DHCP=no
Address=192.168.7.5/24

[Route]
Gateway=192.168.7.1

This now sets up a route metric giving preference to eth0

root@BeagleBone:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.7.1     0.0.0.0         UG    0      0        0 eth0
0.0.0.0         192.168.7.1     0.0.0.0         UG    100    0        0 usb0
192.168.6.0     0.0.0.0         255.255.255.0   U     0      0        0 usb1
192.168.7.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.7.0     0.0.0.0         255.255.255.0   U     0      0        0 usb0


1 Like

Thanks Benedict ; I need to digest your information