Configuring the USB connection as Ethernet (and use for hotspot)

simply, I have a device with usb tethering (usb0 adaptor) and i want to use it for hotspot

  1. how to config usb tethering as a network adaptor in dietpi-config?
  2. even if I do that, will hotspot software (from dietpi-software) work with it?

thanks for support

@MichaIng
@Joulinar

This is a known limitation of our script, which cannot recognise the usb0 network interface actually. Therefore, a manual configuration would be required to set up your usb0 adapter.

As for the hotspot, you can have a look at the following post. Some adjustments are required to get it working. WiFi HotSpot and G_Ether

1 Like

yeah did it and i was able to install hotspot
but there is another problem : i don’t have access to internet over hotspot
i couldn’t even ping devices


[  OK  ] DietPi-Software | mkdir -p /mnt/dietpi_userdata/Music /mnt/dietpi_userdata/Pictures /mnt/dietpi_userdata/Video /mnt/dietpi_userdata/downloads /var/www /opt /usr/local/bin
[  OK  ] DietPi-Software | chown dietpi:dietpi /mnt/dietpi_userdata/Music /mnt/dietpi_userdata/Pictures /mnt/dietpi_userdata/Video /mnt/dietpi_userdata/downloads
[  OK  ] DietPi-Software | chmod 0775 /mnt/dietpi_userdata/Music /mnt/dietpi_userdata/Pictures /mnt/dietpi_userdata/Video /mnt/dietpi_userdata/downloads
[ SUB1 ] DietPi-Services > stop
[  OK  ] DietPi-Services | stop : cron
[  OK  ] DietPi-Services | stop : nginx
[  OK  ] DietPi-Services | stop : avahi-daemon
[ INFO ] DietPi-Software | APT update, please wait...
Hit:1 https://deb.debian.org/debian bullseye InRelease
Hit:2 https://deb.debian.org/debian bullseye-updates InRelease
Hit:3 https://deb.debian.org/debian-security bullseye-security InRelease
Hit:4 https://archive.raspberrypi.org/debian bullseye InRelease
Hit:5 https://deb.debian.org/debian bullseye-backports InRelease
Reading package lists...
[  OK  ] DietPi-Software | APT update

 DietPi-Software
─────────────────────────────────────────────────────
 Step: Installing WiFi Hotspot: turn your device into a WiFi hotspot

[ INFO ] DietPi-Software | APT install hostapd isc-dhcp-server iptables libnl-3-200, please wait...
Reading package lists...
Building dependency tree...
Reading state information...
iptables is already the newest version (1.8.7-1).
libnl-3-200 is already the newest version (3.4.0-1+b1).
Suggested packages:
  policykit-1 isc-dhcp-server-ldap
Recommended packages:
  isc-dhcp-common policycoreutils
The following NEW packages will be installed:
  hostapd isc-dhcp-server libirs-export161 libisccfg-export163
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 1801 kB of archives.
After this operation, 4332 kB of additional disk space will be used.
Get:1 https://deb.debian.org/debian bullseye/main arm64 hostapd arm64 2:2.9.0-21 [764 kB]
Get:2 https://deb.debian.org/debian bullseye/main arm64 libisccfg-export163 arm64 1:9.11.19+dfsg-2.1 [270 kB]
Get:3 https://deb.debian.org/debian bullseye/main arm64 libirs-export161 arm64 1:9.11.19+dfsg-2.1 [244 kB]
Get:4 https://deb.debian.org/debian bullseye/main arm64 isc-dhcp-server arm64 4.4.1-2.3+deb11u2 [524 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 1801 kB in 1s (1226 kB/s)
                                 Selecting previously unselected package hostapd.
(Reading database ... 28113 files and directories currently installed.)
Preparing to unpack .../hostapd_2%3a2.9.0-21_arm64.deb ...
Unpacking hostapd (2:2.9.0-21) ...
Selecting previously unselected package libisccfg-export163.
Preparing to unpack .../libisccfg-export163_1%3a9.11.19+dfsg-2.1_arm64.deb ...
Unpacking libisccfg-export163 (1:9.11.19+dfsg-2.1) ...
Selecting previously unselected package libirs-export161.
Preparing to unpack .../libirs-export161_1%3a9.11.19+dfsg-2.1_arm64.deb ...
Unpacking libirs-export161 (1:9.11.19+dfsg-2.1) ...
Selecting previously unselected package isc-dhcp-server.
Preparing to unpack .../isc-dhcp-server_4.4.1-2.3+deb11u2_arm64.deb ...
Unpacking isc-dhcp-server (4.4.1-2.3+deb11u2) ...
Setting up hostapd (2:2.9.0-21) ...
Created symlink /etc/systemd/system/multi-user.target.wants/hostapd.service β†’ /lib/systemd/system/hostapd.service.
Job for hostapd.service failed because the control process exited with error code.
See "systemctl status hostapd.service" and "journalctl -xe" for details.
Created symlink /etc/systemd/system/hostapd.service β†’ /dev/null.
Setting up libisccfg-export163 (1:9.11.19+dfsg-2.1) ...
Setting up libirs-export161 (1:9.11.19+dfsg-2.1) ...
Setting up isc-dhcp-server (4.4.1-2.3+deb11u2) ...
Generating /etc/default/isc-dhcp-server...
Job for isc-dhcp-server.service failed because the control process exited with error code.
See "systemctl status isc-dhcp-server.service" and "journalctl -xe" for details.
invoke-rc.d: initscript isc-dhcp-server, action "start" failed.
● isc-dhcp-server.service - LSB: DHCP server
     Loaded: loaded (/etc/init.d/isc-dhcp-server; generated)
     Active: failed (Result: exit-code) since Mon 2023-06-05 18:47:18 +0330; 23ms ago
       Docs: man:systemd-sysv-generator(8)
    Process: 15689 ExecStart=/etc/init.d/isc-dhcp-server start (code=exited, status=1/FAILURE)
        CPU: 74ms

Jun 05 18:47:16 dpi dhcpd[15704]: before submitting a bug.  These pages explain the proper
Jun 05 18:47:16 dpi dhcpd[15704]: process and the information we find helpful for debugging.
Jun 05 18:47:16 dpi dhcpd[15704]:
Jun 05 18:47:16 dpi dhcpd[15704]: exiting.
Jun 05 18:47:18 dpi isc-dhcp-server[15689]: Starting ISC DHCPv4 server: dhcpdcheck syslog for diagnostics. ...
Jun 05 18:47:18 dpi isc-dhcp-server[15709]:  failed!
Jun 05 18:47:18 dpi isc-dhcp-server[15710]:  failed!
Jun 05 18:47:18 dpi systemd[1]: isc-dhcp-server.service: Control process exited, code=exited, status=1/FAILURE
Jun 05 18:47:18 dpi systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.
Jun 05 18:47:18 dpi systemd[1]: Failed to start LSB: DHCP server.
Processing triggers for libc-bin (2.31-13+rpt2+rpi1+deb11u5) ...
Processing triggers for man-db (2.9.4-2) ...
[  OK  ] DietPi-Software | APT install hostapd isc-dhcp-server iptables libnl-3-200
[  OK  ] DietPi-Software | systemctl stop hostapd isc-dhcp-server
[  OK  ] DietPi-Software | update-alternatives --set iptables /usr/sbin/iptables-nft
[  OK  ] DietPi-Software | update-alternatives --set ip6tables /usr/sbin/ip6tables-nft
[  OK  ] DietPi-Software | systemctl --no-reload unmask hostapd
[ SUB1 ] DietPi-Set_hardware > wifimodules (enable)
[ INFO ] DietPi-Set_hardware | Please wait, enabling WiFi modules...
[ INFO ] DietPi-Set_hardware | Checking for required APT packages: iw wireless-tools wpasupplicant wireless-regdb
[  OK  ] wifimodules enable | Completed
/boot/dietpi/dietpi-software: line 7884: f6666: command not found
[  OK  ] DietPi-Software | /etc/dhcp/dhcpd.conf: backup to /etc/dhcp/dhcpd.conf.bak_050623_5
[ INFO ] DietPi-Software | For a full list of backup items, please see /var/tmp/dietpi/logs/G_BACKUP_FP.db
[  OK  ] DietPi-Software | sed -Ei /(allow-hotplug|auto)[[:blank:]]+wlan/q0 /etc/network/interfaces
[  OK  ] DietPi-Software | Comment in /etc/network/interfaces converted to setting: allow-hotplug wlan0
[  OK  ] DietPi-Software | ip a add 192.168.41.1 dev wlan0
[  OK  ] DietPi-Software | chmod 0600 /etc/hostapd/hostapd.conf
[ SUB1 ] DietPi-Set_hardware > wificountrycode ()
[  OK  ] DietPi-Set_hardware | Setting in /etc/hostapd/hostapd.conf adjusted: country_code=IR
[  OK  ] DietPi-Set_hardware | Desired setting in /etc/wpa_supplicant/wpa_supplicant.conf was already set: country=IR
[  OK  ] DietPi-Set_hardware | iw reg set IR
[  OK  ] DietPi-Set_hardware | Desired setting in /boot/dietpi.txt was already set: AUTO_SETUP_NET_WIFI_COUNTRY_CODE=IR
[  OK  ] wificountrycode IR | Completed
[  OK  ] DietPi-Software | Added setting ieee80211n=1 to end of file /etc/hostapd/hostapd.conf
[  OK  ] DietPi-Software | eval echo 'DAEMON_CONF="/etc/hostapd/hostapd.conf"' > /etc/default/hostapd
[ INFO ] DietPi-Software | Enabling IP forwarding to allow access across network interfaces
net.ipv4.ip_forward = 1
net.ipv6.conf.default.accept_ra = 2
net.ipv6.conf.all.accept_ra = 2
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1

 DietPi-Software
─────────────────────────────────────────────────────
 Step: Finalising install

[  OK  ] DietPi-Software | systemctl daemon-reload
2023-06-05 18:47:28 [ INFO ] DietPi-RAMlog | Storing /var/log to /var/tmp/dietpi/logs/dietpi-ramlog_store...
2023-06-05 18:47:28 [  OK  ] DietPi-RAMlog | Stored /var/log to /var/tmp/dietpi/logs/dietpi-ramlog_store.

 DietPi-Software
─────────────────────────────────────────────────────
 Step: Install completed

[ INFO ] DietPi-Software | Enabling installed services
[  OK  ] DietPi-Software | systemctl --no-reload enable hostapd
[  OK  ] DietPi-Software | systemctl --no-reload enable isc-dhcp-server
[  OK  ] DietPi-Survey | Purging survey data
[ SUB1 ] DietPi-Services > restart
[  OK  ] DietPi-Services | restart : avahi-daemon
[  OK  ] DietPi-Services | restart : nginx
[  OK  ] DietPi-Services | restart : cron
[ INFO ] DietPi-Software | Starting installed services not controlled by DietPi-Services
[  OK  ] DietPi-Software | systemctl start hostapd
[  OK  ] DietPi-Software | systemctl start isc-dhcp-server

╭─ ~ ξ‚°                                   ξ‚² βœ” ξ‚³ 1m 18s ξ‚³ root@dpi ξ‚³ 06:47:35 PM
╰─ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 396  bytes 51959 (50.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 396  bytes 51959 (50.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.42.252  netmask 255.255.255.0  broadcast 192.168.42.255
        ether 02:75:7c:1d:25:50  txqueuelen 1000  (Ethernet)
        RX packets 19553  bytes 14153972 (13.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 23650  bytes 2992629 (2.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.41.1  netmask 255.255.255.255  broadcast 0.0.0.0
        ether e4:5f:01:2f:72:5f  txqueuelen 1000  (Ethernet)
        RX packets 22555  bytes 908839 (887.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 149  bytes 15762 (15.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

installation log
(i’m sure that i have access to internet over usb0 and i’m using it right now)

edit #1 : i did

dhclient wlan0

and then i was able to access to local network but still cant connect to internet

question: If you are on the DietPi device themself, you are able to ping something on the internet?

Can you share following

ip r

Probably something missing on the routing/forwarding settings.

@tsalehm At:
https://github.com/MichaIng/DietPi/blob/b3f2312cae484e48b3d8451ef5b0238a5ca6a22c/dietpi/dietpi-software#L7884
Did you replace

local eth_iface=$(G_GET_NET -t eth iface)

with

local eth_iface=usb0

?

Because the script subsequently uses $eth_iface to setup NAT rules.

1 Like

works fine with usb tethering!