With multiple boxes around, it may be hard to remember the hostname or IP address of each box, and be certain which box one is connected to. One solution is to connect directly with a cable to the box's front USB connector.
This post describes how to set up the box such that plugging a USB-to-Ethernet adapter into the front USB port and connecting it to a PC with an Ethernet cable gives access to the box through ssh, https, etc at a fixed address, say 192.168.100.100. The only things needed are a USB-to-Ethernet adapter (see attached picture) and an Ethernet cable.
1. Make the USB network interface start automatically
Plug the USB-to-Ethernet adapter into the front USB connector and use 'dmesg' to get its name as a network interface:
Unplug the sdspter, make a copy of '/etc/network/interfaces' and add some lines to it:
Plug in the USB-to-Ethernet adapter and verify that it becomes network interface 'usb0' with address 192.168.100.100:
2. Install and configure the DHCP server
DHCP is the service that provide a connected PC with a suitable IP address. Install the server:
The reported error may be ignored. Make a copy of '/etc/dhcp/dhcpd.conf' and modify it:
3. Make the DHCP service start automatically on 'usb0'
Make a copy of '/etc/default/isc-dhcp-server' and modify it:
Make 'udev' restart the DHCP server when the USB-to-Ethernet adapter is plugged in:
4. Verification
On the PC, to avoid routing issues, disable any wireless network interface and unplug any Ethernet cables. Plug the USB-to-Ethernet adapter into the box and connect an Ethernet cable between it and the PC.
Open a new local terminal/command window on the PC and check that the PC's IP address is '192.168.100.xx':
Check that 'ping' works:
Check that 'ssh' works:
5. Trouble shooting
The service port has been tested and verified on Netgear Stora, RN102 and RN104. If the verification failed, read through the above steps carefully, and verify that each step was followed exactly. If still confused:
Above, it's assumed that the box is connected to a router with LAN-address 192.168.1.1, and that the router runs a DNS server translating human readable addresses like 'google.com' into IP addresses like '8.8.8.8'. If this is not the case, minor adjustments might be needed.
Note to Windows users:
'putty' may be used in stead of 'ssh' to access the box, both when configuring it and when accessing it through the service port. And, on the PC, use 'ipconfig' in stead of 'ifconfig'.
Good luck!
Regards,
Trond Melen
This post describes how to set up the box such that plugging a USB-to-Ethernet adapter into the front USB port and connecting it to a PC with an Ethernet cable gives access to the box through ssh, https, etc at a fixed address, say 192.168.100.100. The only things needed are a USB-to-Ethernet adapter (see attached picture) and an Ethernet cable.
1. Make the USB network interface start automatically
Plug the USB-to-Ethernet adapter into the front USB connector and use 'dmesg' to get its name as a network interface:
$ dmesg | tail -4
[498079.883797] asix 1-1:1.0 (unnamed net_device) (uninitialized): PHY [usb-001:005:10] driver [Asix Electronics AX88772A] (irq=POLL)
[498079.898637] Asix Electronics AX88772A usb-001:005:10: attached PHY driver (mii_bus:phy_addr=usb-001:005:10, irq=POLL)
[498079.911504] asix 1-1:1.0 eth2: register 'asix' at usb-d0050000.usb-1, ASIX AX88772 USB 2.0 Ethernet, 01:23:45:67:89:ab
[498079.955400] asix 1-1:1.0 enx0123456789ab: renamed from eth2
Unplug the sdspter, make a copy of '/etc/network/interfaces' and add some lines to it:
$ sudo cp -a /etc/network/interfaces /etc/network/interfaces.orig
$ sudo nano /etc/network/interfaces
$ tail -5 /etc/network/interfaces
rename /enx*=usb0
allow-hotplug usb0
iface usb0 inet static
address 192.168.100.100/24
gateway 192.168.1.1
The kernel's proposed name for the interface ('enx0123456789ab') must match the pattern ('enx*') for renaming it to 'usb0' to work. The slash ('/') just before 'enx*' is not part of the pattern.
Plug in the USB-to-Ethernet adapter and verify that it becomes network interface 'usb0' with address 192.168.100.100:
$ sudo ifconfig
[...]
usb0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.100.100 netmask 255.255.255.0 broadcast 192.168.100.255
ether 01:23:45:67:89:ab txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Unplug the adapter.
2. Install and configure the DHCP server
DHCP is the service that provide a connected PC with a suitable IP address. Install the server:
$ sudo apt install -y isc-dhcp-server [...] Generating /etc/default/isc-dhcp-server... Launching both IPv4 and IPv6 servers (please configure INTERFACES in /etc/default/isc-dhcp-server if you only want one or the other). Starting ISC DHCPv4 server: dhcpdcheck syslog for diagnostics. ... failed! failed! invoke-rc.d: initscript isc-dhcp-server, action "start" failed. [...]
The reported error may be ignored. Make a copy of '/etc/dhcp/dhcpd.conf' and modify it:
$ sudo cp -a /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.orig
$ sudo nano /etc/dhcp/dhcpd.conf
$ diff /etc/dhcp/dhcpd.conf.orig /etc/dhcp/dhcpd.conf
7,8c7,8
< option domain-name "example.org";
< option domain-name-servers ns1.example.org, ns2.example.org;
---
> option domain-name "local";
> option domain-name-servers 192.168.1.1;
107a108,112
>
> subnet 192.168.100.0 netmask 255.255.255.0 {
> range 192.168.100.10 192.168.100.99;
> option routers 198.192.1.1;
> }
3. Make the DHCP service start automatically on 'usb0'
Make a copy of '/etc/default/isc-dhcp-server' and modify it:
$ sudo cp -a /etc/default/isc-dhcp-server /etc/default/isc-dhcp-server.orig $ sudo nano /etc/default/isc-dhcp-server $ tail -4 /etc/default/isc-dhcp-server # On what interfaces should the DHCP server (dhcpd) serve DHCP requests? # Separate multiple interfaces with spaces, e.g. "eth0 eth1". INTERFACESv4="usb0" INTERFACESv6=""
Make 'udev' restart the DHCP server when the USB-to-Ethernet adapter is plugged in:
$ sudo nano /etc/udev/rules.d/85-ifupdown.rules $ cat /etc/udev/rules.d/85-ifupdown.rules # Handle allow-hotplug interfaces SUBSYSTEM=="net", ACTION=="add", RUN+="/etc/init.d/isc-dhcp-server restart" $ sudo udevadm control --reload-rules && sudo udevadm trigger
4. Verification
On the PC, to avoid routing issues, disable any wireless network interface and unplug any Ethernet cables. Plug the USB-to-Ethernet adapter into the box and connect an Ethernet cable between it and the PC.
Open a new local terminal/command window on the PC and check that the PC's IP address is '192.168.100.xx':
$ ifconfig | grep 'inet ' | grep 100
inet 192.168.100.10 netmask 255.255.255.0 broadcast 192.168.100.255
Check that 'ping' works:
$ ping -c 1 192.168.100.100 PING 192.168.100.100 (192.168.100.100) 56(84) bytes of data. 64 bytes from 192.168.100.100: icmp_seq=1 ttl=64 time=0.735 ms --- 192.168.100.100 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.735/0.735/0.735/0.000 ms
Check that 'ssh' works:
$ ssh root@192.168.100.100 The authenticity of host '192.168.100.100 (192.168.100.100)' can't be established. ED25519 key fingerprint is SHA256:fQNAwY0Yy9NsXLyIUMQKByMp7oNOYF1C4O5kPE0iNrM. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '192.168.100.100' (ED25519) to the list of known hosts. root@192.168.100.100's password:Reestablish the PC's wireless and/or cabled network again and repeat the verification.
5. Trouble shooting
The service port has been tested and verified on Netgear Stora, RN102 and RN104. If the verification failed, read through the above steps carefully, and verify that each step was followed exactly. If still confused:
- Check the green and orange LEDs on the Ethernet connectors for line contact and communication.
- On the PC, check that Ethernet is configured to obtain its address automatically through DHCP.
- On the box, messages from the DHCP server may give a hint. They are written to '/var/log/syslog' or Busybox' 'syslogd' in RAM:
$ logread | tail
- On the box, 'dmesg' may give a hint:
$ sudo dmesg | tail
Above, it's assumed that the box is connected to a router with LAN-address 192.168.1.1, and that the router runs a DNS server translating human readable addresses like 'google.com' into IP addresses like '8.8.8.8'. If this is not the case, minor adjustments might be needed.
Note to Windows users:
'putty' may be used in stead of 'ssh' to access the box, both when configuring it and when accessing it through the service port. And, on the PC, use 'ipconfig' in stead of 'ifconfig'.
Good luck!
Regards,
Trond Melen