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?
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?
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 ... 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...
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.
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...
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.
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.
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.
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
}