2

I have a USB device that works as a USB RNDIS ethernet device.

This device does not have DHCP capability so the host computer needs to allocate IP address for itself.

I tried to add to the /etc/network/interfaces

auto usb0
iface usb0 inet static
    address 192.168.7.15
    netmask 255.255.255.0
    network 192.168.7.0

Then I run into the problem similar to this one: when the device is not connected then usb0 will not show, and network-manager would fail at boot.

Is there a way to work around this?

  • No devices have "DHCP capability". It is done by the OS. If you setup interface this way, NM will not manage it anyway. It is totally unclear what are you asking. – Pilot6 Jan 06 '16 at 14:23
  • @Pilot6 I mean, when the device is connected to the host, the device can not allocate an IP address for the host. – user3528438 Jan 06 '16 at 14:45

3 Answers3

2

If you need to plug/unplug very frequently, a HWaddr should bind to the device like this 12:a5:cf:42:92:fd. For my case, I'm using g_ether.ko on an embeded linux system, run "insmod g_ether.ko host_addr=12:a5:cf:42:92:fd dev_addr=5e:bc:ca:27:92:b1". Then on the linux host (Ubuntu 12.04 LTS for my case), edit the file "/etc/NetworkManager/system-connections/Wired connection 2", and input something like

####################################
[802-3-ethernet]

duplex=full
mac-address=12:a5:cf:42:92:fd

[connection]

id=Wired connection 2
uuid=2862a666-c2e6-4a3a-8e0c-8705d93c92da
type=802-3-ethernet
timestamp=1501735507

[ipv6]

method=auto

[ipv4]

method=manual

addresses1=192.168.42.21;24;192.168.42.1;
###############################################

Last, save the file, and plug/replug the usb cable.

y. Liu
  • 86
  • You are right. The reason the host side can not remember the IP settings is the device side uses a different mac address each time the module is mounted. So the solution is to use module parameters to set a fixed mac, preferably a device unique value on boot and when the module is mounted. – user3528438 Aug 03 '17 at 10:38
0

Ok either you properly enable and run the NM or just purge/remove the NM and add an entry to /etc/network/interfaces like this:

        auto usb0
        iface usb0 inet dhcp

then restart the box or just the networking service

I hope it will get the ip. try it.

And make sure that the drivers for that USB device are installed

  • Because this is a peer-to-peer direct connection and there is not DHCP server, so the two sides needs to allocate/configure IP address for themselves. I'm trying to hard code an IP address in /etc/network/interfaces which caused problems. – user3528438 Jan 06 '16 at 14:46
  • Ok , remove network manager and then hard code it on both sides , they should be on the same subnet – Ijaz Ahmad Jan 06 '16 at 14:49
  • Then how would other adapters work if network manager is disabled? – user3528438 Jan 06 '16 at 14:55
  • I am using wireless adapter without NM. NM had many problems so i removed it – Ijaz Ahmad Jan 06 '16 at 15:35
0

You can change the settings for that specific connection by choosing Edit Connections in the drop-down menu for the Network Manager icon in the panel. In this dialog, select the wired connection in question, choose to edit it, go to the IPv4 tab, and change to Manual connection. There are also other link-local and such type connections you can use if necessary.

dobey
  • 40,982
  • 1
    Well, I know this approach but everytime the device is connected, it creates a new connection, and I need to manually change the settings everytime. Since I need to plug/unplug and boot/reboot the device very frequently, I'm trying to figure out a way to make the settings persistent. – user3528438 Jan 06 '16 at 15:31
  • That sounds like a bug in network-manager then, and you should report it. – dobey Jan 06 '16 at 16:20