i came accross a problem i was yet unable to solve with my raspberry pi.
what i want is the following:
- startup wifi on boot with no ethernet connected
- when plugging in ethernet cable switch to ethernet and stop wifi
- when removing ethernet cable restart wifi
before posting my config files i will explain what is happening right now:
- wifi starts up on boot, i can login via ssh and everything works fine
when i plugin ethernet, the wifi goes down and the pi is then accessible through the ethernet ip.
But here is where the problems start:
i cannot access the internet through this, as there is no default gateway set!
sure i can just type route add default gw xxx.xxx.xxx.xxx but i want this to work
when i remove the ethernet cable the wifi seems to startup again (light flickering on the dongle) but it is not accessible anymore
neither via ssh nor through port 80 or antyhing else
i already invested many hours on google to find information on the subject, and honestly there is alot of information out there. sadly many answers are very different, yet they seem to work for someone or the other. my files currently look like a mix of the many different things i found on the web. i hope you can help me to get this working, or explain to me that what i want is not possible and why.
ARGS="-q -f -u0 -d10 -w -I"
iface lo inet loopback
iface eth0 inet static
address 192.168.0.99 netmask 255.255.255.0 gateway 192.168.0.254 post-up route add default gw 192.168.0.254 pre-down route del default gw 192.168.0.254
iface wlan0 inet manual
iface wifi inet static
address 192.168.0.89 netmask 255.255.255.0 #gateway 192.168.0.254 post-up route add default gw 192.168.0.254 pre-down route del default gw 192.168.0.254
iface default inet dhcp
post-up route add default gw 192.168.0.254
pre-down route del default gw 192.168.0.254
as you can see i disabled the power management on the wifi and tried to add the gateway after either interface comes up.
as far as i can tell these pre and post lines don't have any effect at all, since, as described earlier, there is no gateway set after i plug in the ethernet cable.
i also tried setting the gateway on both eth0 AND wlan0 which resulted in the wlan not being accessible at all. so i have it commented out on one of them.
i hope you guys can help me with an answer, as it's driving me nuts.
thank you very much for your time and effort.