# Trouble setting up wired/wireless connection failover

## zithy

I have a laptop with a wireless and a wired connection to the lan.  

I want to be able to unplug the ethernet cable and keep my network connection up.

I am a noob when it comes to networking, and have been trying to follow the Linux Advanced Routing and Traffic Control Howto at

http://lartc.org/howto/index.html

and an entry at gentoo-wiki.com which I can't seem to connect to at the moment.

I am missing something because when I ping a machine on my network, the ping dies with I pull the cable.

Here is what I have done so far.

/etc/conf.d/net contains 

```
modules=( "iproute2" )

config_eth0=(

        "10.0.0.151/24 brd 10.0.0.255"

)

config_wlan0=(

        "10.0.0.158/24 brd 10.0.0.255"

)

#routes_eth0=(

#        "default via 10.0.0.1"

#)

#routes_wlan0=(

#        "127.0.0.0/8 dev lo table wireless"

#        "default via 10.0.0.1 table wireless"

#)

```

/etc/conf.d/local.start contains

```
ip route add 10.0.0.0/24 dev eth0 src 10.0.0.151 table wired_table

ip route add default via 10.0.0.150 table wired_table

ip route add 10.0.0.0/24 dev wlan0 src 10.0.0.158 table wireless_table

ip route add default via 10.0.0.150 table wireless_table

# route things to the direct neighbour throught the closest interface

ip route add 10.0.0.0/24 dev eth0 src 10.0.0.151

ip route add 10.0.0.0/24 dev wlan0 src 10.0.0.158

# specify preference for routes

ip route add default via 10.0.0.150

# set up the routing rules

#  these choose what routing tabe to route with

#  you want to make sure that you route out a given interface if you already

#      have the corresponding source address

ip rule add from 10.0.0.151 table wired_table

ip rule add from 10.0.0.158 table wireless_table

```

/etc/iproute2/rt_tables contains

```
#

# reserved values

#

255     local

254     main

253     default

0       unspec

#

# local

#

#1      inr.ruhep

100     wireless_table

101     wired_table

```

If there is another better way to do this please let me know.

I just latched on to this method because it sounded like it was the right way to go.

After I get this working on my laptop I am going to try it on another computer that would tend to lose its connection between a small switch and the rest of the network, so detecting when the ethernet cable is unplugged is not a good option.

Thanks in advance.Last edited by zithy on Tue Nov 29, 2005 11:25 pm; edited 2 times in total

----------

## MrUlterior

Just bridge the two interfaces to "br0" and be done with it. Or if you consider security important, setup OpenVPN and bridge that with your wired LAN interface.

----------

## zithy

I have tried bridging and bonding trying to get this to work.

For both bonding and bridging ifconfig shows the virtual device and the physical devices, and iwconfig tells me wlan0 is connected to my access point.

Here is my setup for bonding.

/etc/conf.d/net contains

```
#

# Trying to set up bonding

####

# bond these interfaces together

slaves_bond0="wlan0 eth0"

# assign an ip address (or null for no ip) to the bond device

config_bond0=(

       "10.0.0.151 netmask 255.255.255.0"

#       "null"

)

routes_bond0=(

       "default via 10.0.0.1"

)

# The bond device depends on eth0 and wlan0, so load it after them

depend_bond0() {

       need net.wlan0 net.eth0

}
```

With this setup dmesg gives an error saying that bond0 has the same MAC address as the permanent address of eth0.

I have tried adding 

```
mac_bond0="00:11:22:33:44:55"
```

or

```
mac_eth0="00:11:22:33:44:55"
```

but was not able to change the output of ifconfig with that.

If I ping 10.0.0.1 and unplug the cable, pings are dropped.

Here is my setup for bridging.

/etc/conf.d/net contains

```
#

# Setup Bridge

####

# add ports to bridge br0

bridge_br0="eth0 wlan0"

# configure the ip address for eth0 and wlan0 to null so that dhcp is not used

config_eth0=( "null" )

config_wlan0=( "null" )

# Setup br0 as dependent on wlan0 so that the wireless gets setup first

depend_br0() {

        need net.wlan0 net.eth0

}

config_br0=(

        "10.0.0.151 netmask 255.255.255.0"

)
```

If I ping 10.0.0.1 and pull the cable I lose the connection.

I have tested both eth0 and wlan0 seperately, and they work fine, but I can't get them to fail over for eash other.

----------

## UberLord

Or just emerge baselayout-1.12.0_pre11-r3, netplug and wpa_supplicant-0.4.x (if it supports your wireless card, madwifi is currently broken)

Then set RC_AUTO_INTERFACE="yes" in /etc/conf.d/rc

Weeeeeee, now regardless of which interface is up we can talk to the lan. We also prefer wired over wireless (achieved via metrics) and optionally merge resolv.conf, ntp.conf and nis.conf if they're on different networks.

netplug brings the wired interface up/down if the cable is in/out

wpa_supplicant does the same thing but for wireless interfaces.

How easy was that?   :Cool: 

No need for a bridge either  :Wink: 

----------

## zithy

Thanks UberLord.

Your method works for some of the failure conditions that I am looking at, but not all.

Here is what is missing.

PC Ethernet----1----SWITCH----2----LAN

PC Wireless----3----WIreless AP----4----LAN

The above solution works for failures at points 1 and 3, but I need something that works for failures at points 2 and 4 as well.

----------

## UberLord

Switch goes down - then no link beat is detected so ifplugd stops -  solved!

AP goes down, wpa_supplicant stops - solved!

If the LAN goes down, then you're SOL - but no solution here will solve that.

I fail to see how my solution does not fit your requirements - maybe I am blind!   :Rolling Eyes: 

----------

## zithy

I tried pulling the cable and it didn't switch over.

Maybe I should explain more what I am trying to do.

I am an engineer working on a audio/video streaming device that is based on linux.

We have three stations that are networked.

Station 1 has some IP cameras, IP audio devices, and a wireless AP/5 port switch.

It is connected to Station 2 with an ethernet cable.

Station 2 has a some audio stuff in it and a switch with ethernet cables going to station 1 and 3.

Station 3 has a switch in it with one or more pcs connected, and the cable going to Station 2.

If the ethernet cable is broken between station 1 and 2 or 2 and 3 I want a pc connected to station 3 to connect to the wireless ap in station 1 through a usb wireless device.

 *Quote:*   

> If the LAN goes down, then you're SOL - but no solution here will solve that. 

 

I hope that I am not there  :Confused: 

The backup plan is to write custom scripts to run on the pcs that will manually switch if the link stops functioning.

So, am I killing the LAN and working myself out of nice solutions with this network topology, or am I missing something else?

----------

