![]() |
[SOLVED] Dynamic Network Config - Printable Version +- Forum (http://forum.xbian.org) +-- Forum: Hardware (/forum-7.html) +--- Forum: Network (/forum-25.html) +--- Thread: [SOLVED] Dynamic Network Config (/thread-2062.html) |
Dynamic Network Config - mdkeil - 27th Jan, 2014 08:01 PM Hello, first I want to say thank you for the nice rasPi-OS. I'm using it since yesterday with no further problems. At the moment I used two different network profiles and I wanna try to change the config with automatic events. 1. Profile: Xbian used local Wifi-Connection (wlan0 dhcp) (works) 2. Profile: XBian used the "usb-tethered" (usb0) inet-connection from my smartphone and operates in AP-mode (wlan0 static IP + hostapd + dhcpd) to forward the inet to all user of the AP (works) Now I need some help to make this automatically. 1) hot plug usb0 -> switch from local wifi-connection (or whatever ;D ) to AP-mode on with forwarding usb0-inet 2) usb0 down -> AP-mode off -> switch to local wifi-connection if available 3) no local wifi-connection available and usb0 down -> AP-mode on, without forward any inet-connection I can allways connect to raspi via ssh now. Therefore I need some scripting help. RE: Dynamic Network Config - IriDium - 2nd Feb, 2014 03:26 AM Whilst I think this might be possible with Raspbian - I doubt it would be - at the moment - possible with Xbian. The startup checks for ETH0 and if not available checks for WLAN0 - what you are proposing requires a rewrite of the Xbian startup scripts. So for the moment I think you are on your own. NB: Note that any system changes you do could be overwritten by any upgrades. RE: Dynamic Network Config - mk01 - 3rd Feb, 2014 10:19 AM @IriDium nope! if you remove eth0 from "auto" (so you disable auto on eth0), eth0 will just be tested for 3s if has physical link. if not, no problem and eth0 is not considered as requirement. "lo" will make all requirements satisfied. wlan0 is completely left as default (hot plug reacting on udev event - wlan0 plugged in - only). @mdkeil I would do it though one upstart job, "task" - triggered on "net-device-up" and "net-device-down" (each has parameters IFACE and INTERFACE (being the same value)). and actual interface status is "test -e /run/network/ifup.$IFACE". with this script you easily do the "automatic". and specials you can put into "/etc/network/if-*" folders, according the name and functions. they get automatically called. parameters are again IFACE and INTERFACE . RE: Dynamic Network Config - mdkeil - 3rd Feb, 2014 03:59 PM Good morning, thanks for the answers an ideas, i will post my solution next weekend. Actually wlan0 will try to to connect an knowing SSID after startup. Every 15 minutes cron-deamon starts a script looking (via ping) if raspi is connecting to ihe inet and switch to AP-mode when no inet is established. USB0 i will look further with "/etc/network/if-*folders". RE: Dynamic Network Config - mk01 - 3rd Feb, 2014 05:14 PM in such setup: put wlan0 as AUTO when wlan0 gets connected, ifup will call /etc/network/if-up.d/* scripts. so you don't have tp check, just put your script into this folder and filter your IFACE=wlan0 but if I get it roght: your network adapters are always attached? or wlan0 always is and usb0 is hotplug? then yes, put wlan0 as auto, usb0 as hotplug. create one upstart job started and stopped on "net-device-added usb0" and "net-device-removed usb0". in pre-start put wlan0 to AP and post-stop wlan0 going from AP to auto. that's all. if specific firewalling needs to be set, put it into post-start of the usb0 script. and you are done. no cron, just events so minimum workload. RE: Dynamic Network Config - mdkeil - 15th Feb, 2014 10:57 PM thxs, now I want to use a second dongle for building a repeater. I only have one problem, because the device-name (wlan0/wlan1) was switching between both wifi-dongles. I tryed to make the name fix by using udev-rules, but it doesnt work. I think udevd doesnt use the rule. Code: sudo nano /etc/udev/rules.d/10-wlan_stick.rules EDIT: Now it works! Code: sudo nano /etc/udev/rules.d/70-persistent-net.rules |