Help configuring a Wifi HDD

Hi,

I picked up a Macally wifihdd on ebay and after some investigation found out it is the exact same board as the intenso m2m https://openwrt.org/toh/intenso/m2m. So I connected serial and flashed it with OpenWrt18.06.4. The device is a usb 3.0 hard drive enclosure with fast ethernet and wifi. I currrently have it configured as access point which uses dhcp client to get an ip address from the router and shares the connection over wifi. This works fine and I can use samba to access the files on the drive. However when I disconnect the ethernet cable the device loses the ip address and I can't access the files any more. Is there a way to configure OpenWrt such that it switches to a fixed ip address when dhcp client does not find a connection on eth0?

My current network config is as follows:

typeconfig interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option ula_prefix 'fd8d:367e:2795::/48'

config interface 'lan'
	option type 'bridge'
	option ifname 'eth0'
	option proto 'dhcp'
	option delegate '0'

config device 'lan_dev'
	option name 'eth0'
	option macaddr '00:1c:c2:0f:07:85'

config switch
	option name 'switch0'
	option reset '1'
	option enable_vlan '0'

Thanks

you could probably do something with travelmate and/or some custom triggers...

do you really need both LAN and WIFI dynamically switched?

personally, i'd just run LAN on an alternate range... give my "LAN-enabled" client an additional virtual-ip in that range....

having a device switch over itself is a recipe for reset-time...

1 Like

Thanks for the travelmate suggestion. That seems to do what I want but with wifi instead of ethernet connection so I may install it on a spare router and try to understand what it does.

I guess another option is to write a hotplug or init script which checks if eth0 is connected and adjusts the network config based on that.

I'm not sure what you mean with an additional virtual ip in a different range. Is it possible to give a device more than one ip address?

yup... you have to jump a few more hoops if the client "primary"(normal-network) ip is dynamic....

the client "secondary" ip would be in an alternate range that is permanently assigned to the HDD LAN port ...

then you can switch the HDD wireless ip to your hearts content... and not loose your "failsafe" connection...

OK cool, I didn't know that. I'll have to do some googling to see how that works. I guess the main thing to do is choose a secondary fixed ip which is not being used by any router such that there are no conflicts between dhcp and the fixed ip. Are there specific ip ranges that should be used for this?

something like this... then you can change the router normal LAN to dynamic of you want... cause you've got a backup :wink: ... ip's in 10.x.x.x(/8+) 172.16-31.x.x(/16+) and 192.168.x.x(/16+) are safe... web search for more info...

web search for adding an "additional ip" on your client ( i.e. 192.168.77.2 ) not too hard...

config interface 'lansafe'
	option proto 'static'
	option netmask '255.255.255.0'
	option ipaddr '192.168.77.1'
	option ifname '@lan'

( note: i put a sticker on the bottom of devices with the "failsafe details" cause i forget :wink: )

you might also have to assign LAN firewall zone to that interface... not too sure about that one...

I've modified the network and dhcp config and this allows me to connect to the wifihdd via wifi independent if the ethernet cable is plugged in or not so that fixes the issue. However the device does no longer pass the internet connection to the wifi when the ethernet cable is plugged in. I know the wifihdd is connected to the internet since I can ping google etc when I'm ssh-ed into the device. My laptop and phone always get an ip in the range 192.168.77.* and not one from my router via dhcp 192.168.1.* when the ethernet cable is connected. I'm not sure if this is something that needs to be changed on the phone / laptop side or if this can be changed on the wifihdd. Below are my current configs.

/etc/config/network

config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fdc9:39c2:6ca6::/48'

config interface 'lan'
        option type 'bridge'
        option ifname 'eth0'
        option proto 'dhcp'
        option delegate '0'

config interface 'lan2'
        option type 'bridge'
        option ifname 'eth0'
        option proto 'static'
        option ipaddr '198.168.77.1'
        option netmask '255.255.255.0'
        option delegate '0'

config device 'lan_dev'
        option name 'eth0'
        option macaddr '00:1c:c2:0f:07:85'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '0'

/etc/config/dhcp

config dnsmasq
        option domainneeded '1'
        option boguspriv '1'
        option filterwin2k '0'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option nonegcache '0'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.auto'
        option nonwildcard '1'
        option localservice '1'

config dhcp 'lan'
        option interface 'lan'
        option ignore '1'

config dhcp 'lan2'
        option interface 'lan2'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv6 'server'
        option ra 'server'
        option ra_management '1'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'

When the device is connected to the main router, only the main router must handle DHCP requests; but when the device is not connected, it must act as a DHCP server. And when it is connected again to the main router, you are going to have conflicting IP addresses...

You can configure the device as a router, but having isolated networks is going to be unpleasant, too...

I do not see an easy solution.

Yes I think I may need to go down a different route and write an init script that starts the device as access point and if it does not establish a connection on eth0 it would switch over to act as a router. This script would only happen during startup and then stay like that until rebooted.

i use relayd with a KIMAX U25-AWF-H1

you can add also minidlna


fstab

config global
	option anon_swap '0'
	option anon_mount '0'
	option auto_swap '1'
	option auto_mount '1'
	option delay_root '5'
	option check_fs '0'

config mount
	option enabled '1'
	option device '/dev/sda1'
	option target '/mnt/sda1'

config mount
	option enabled '1'
	option device '/dev/sda2'
	option target '/mnt/sda2'

config mount
	option enabled '1'
	option device '/dev/sda3'
	option target '/mnt/sda3'


samba

config samba
	option workgroup 'WORKGROUP'
	option interface 'br-lan,eth0,wlan0'
	option homes '1'
	option name 'U25AWF-H1-030'
	option description 'U25AWF-H1-030'

config sambashare
	option browseable 'yes'
	option read_only 'no'
	option guest_ok 'yes'
	option name 'HDD INTERNE'
	option path '/mnt/'


dhcp

config dnsmasq
	option localise_queries '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/lan/'
	option domain 'lan'
	option expandhosts '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option nonwildcard '1'
	option localservice '1'

config dhcp 'lan'
	option interface 'lan'
	option dhcpv6 'server'
	option ra 'server'
	option ra_management '1'
	option ignore '1'

config dhcp 'wan'
	option interface 'wan'
	option ignore '1'

config odhcpd 'odhcpd'
	option maindhcp '0'
	option leasefile '/tmp/hosts/odhcpd'
	option leasetrigger '/usr/sbin/odhcpd-update'
	option loglevel '4'

config dhcp 'wwan'
	option interface 'wwan'
	option ignore '1'


wireless


config wifi-device 'radio0'
	option type 'mac80211'
	option hwmode '11g'
	option path 'platform/10180000.wmac'
	option country 'FR'
	option channel '3'
	option htmode 'HT20'

config wifi-iface 'wifinet0'
	option ssid 'Livebox-6256'
	option device 'radio0'
	option mode 'sta'
	option bssid '8C:F8:13:29:XX:XX'
	option encryption 'psk-mixed'
	option key '1234567890'
	option network 'wwan'

config wifi-iface 'wifinet1'
	option device 'radio0'
	option mode 'ap'
	option ssid 'OpenWrt-030'
	option key '1234567890'
	option wpa_disable_eapol_key_retries '1'
	option encryption 'psk-mixed'
	option network 'wwan lan'

firewall


config defaults
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'REJECT'
	option syn_flood '1'

config zone
	option name 'lan'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'ACCEPT'
	option network 'lan wwan'

config include
	option path '/etc/firewall.user'

config include 'miniupnpd'
	option type 'script'
	option path '/usr/share/miniupnpd/firewall.include'
	option family 'any'
	option reload '1'

network


config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option ula_prefix 'fd6c:739e:xxxx::/48'

config interface 'lan'
	option type 'bridge'
	option proto 'static'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option ipaddr '192.168.2.030'
	option ifname 'eth0'
	option gateway '192.168.1.1'
	option metric '0'
	option ip6hint '0'
	list dns '192.168.1.1'
	option delegate '0'
	option broadcast '192.168.1.255'

config interface 'stabridge'
	option proto 'relay'
	list network 'lan'
	list network 'wwan'
	option delegate '0'
	option ipaddr '192.168.1.30'
	option forward_bcast '0'
	option forward_dhcp '0'
	option table '16800'

config interface 'wwan'
	option proto 'static'
	option ipaddr '192.168.1.030'
	option netmask '255.255.255.0'
	option gateway '192.168.1.1'
	option broadcast '192.168.1.255'
	option metric '0'
	list dns '192.168.1.1'
	option delegate '0'


If I understand your config correctly you use your device as a wireless repeater as described here: https://openwrt.org/docs/guide-user/network/wifi/relay_configuration which is different from what I am trying to achieve:

  1. If I get to a hotel / airbnb I would like to be able to connect the Wifi HDD with an ethernet cable to the router and share the internet connection via wifi.

  2. When there is no cabled connection available I want to setup the Wifi HDD as wireless router such that different clients (phone / tablet) can connect and download / share the files on the hard drive.

I'm not sure how to achieve this in a single setup. At the moment I'm looking at creating an init script which starts the device as access point. If no connection to the internet becomes available it will load a different network config and restart the network as router.

this:

https://openwrt.org/docs/guide-user/network/wifi/ap_sta

also exist TravelMate

I've created the following init script which changes the network settings depending if the wifihdd is connected via the ethernet cable. It is probably not the nicest solution but it works.

#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org

START=99
boot() {
        # always start WifiHDD as acccess point

        /etc/init.d/network stop

        cp /etc/config/network-AP /etc/config/network

        /etc/init.d/network start

        sleep 10

        # check wifihdd is connected and configured as AP 
        # if not connected change network config to static IP and reload network service

        ping -c 1 -t 10 google.co.uk &> /dev/null || /etc/init.d/network stop ; cp /etc/config/network-static /etc/config/network ; /etc/init.d/network start
}

1 Like

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.