Add some description about how to failover between wired and wireless

interface, and how to do it with rc.conf, which is quite useful for
laptop users.

Reported by:	jpaetzel
Sponsored by:	iXsystems, Inc
This commit is contained in:
Xin LI 2010-01-13 08:29:29 +00:00
parent fd00138359
commit 04e0947e28
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=35179

View file

@ -2077,6 +2077,25 @@ freebsdap 00:11:95:c3:0d:ac 1 54M 22:1 100 EPS</screen>
</sect3>
</sect2>
<sect2>
<title>Using both wired and wireless connection</title>
<para>Wired connection provides better performance and reliability,
while wireless connection provides flexibility and mobility,
users of laptop computers usually want to combine these together
and roam seamlessly between the two.</para>
<para>On &os;, it is possible to combine two or even more network
interfaces together in a <quote>failover</quote> fashion, that
is, to use the most preferred and available connection from a
group of network interfaces, and have the operating system to
switch automatically when the link state changes.</para>
<para>We will cover link aggregation and failover in <xref linkend="network-aggregation">
where an example for using both wired and wireless connection
is also provided at <xref linkend="networking-lagg-wired-and-wireless">.</para>
</sect2>
<sect2>
<title>Troubleshooting</title>
@ -3401,6 +3420,85 @@ lagg0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 150
become the active link. If the link is restored on the master
interface then it will once again become the active link.</para>
</example>
<example id="networking-lagg-wired-and-wireless">
<title>Failover mode between wired and wireless interfaces</title>
<para>For laptop users, it is usually desirable to make wireless as a
secondary interface, which is to be used when the wired connection
is not available. With &man.lagg.4;, it is possible to use one
IP address, prefer the wired connection for both performance and
security reasons, while maintaining the ability to transfer data
over the wireless connection.</para>
<para>In this setup, we will need to override the underlying
wireless interface's <acronym>MAC</acronym> address to match the &man.lagg.4;'s,
which is inherited from the master interface being used, the
wired interface.</para>
<para>In this setup, we will treat the wired interface,
<replaceable>bge0</replaceable>, as the master, and the wireless
interface,
<replaceable>wlan0</replaceable>, as the failover interface. The
<replaceable>wlan0</replaceable> was created from
<replaceable>iwn0</replaceable> which we will set up with
the wired connection's <acronym>MAC</acronym> address. The first step would be
to obtain the <acronym>MAC</acronym> address from the wired interface:</para>
<screen>&prompt.root; <userinput>ifconfig <replaceable>bge0</replaceable></userinput>
bge0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
options=19b&lt;RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4&gt;
ether 00:21:70:da:ae:37
inet6 fe80::221:70ff:feda:ae37%bge0 prefixlen 64 scopeid 0x2
nd6 options=29&lt;PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL&gt;
media: Ethernet autoselect (1000baseT &lt;full-duplex&gt;)
status: active</screen>
<para>You can replace the <replaceable>bge0</replaceable> to match
your reality, and will get a different <literal>ether</literal>
line which is the <acronym>MAC</acronym> address of your wired interface. Now,
we change the underlying wireless interface,
<replaceable>iwn0</replaceable>:</para>
<screen>&prompt.root; <userinput>ifconfig <replaceable>iwn0</replaceable> ether <replaceable>00:21:70:da:ae:37</replaceable></userinput></screen>
<para>Bring up the wireless interface but don't set up any IP
address on it:</para>
<screen>&prompt.root; <userinput>ifconfig create <replaceable>wlan0</replaceable> wlandev <replaceable>iwn0</replaceable> ssid <replaceable>my_router</replaceable> up</userinput></screen>
<para>Create the &man.lagg.4; interface with <replaceable>bge0</replaceable>
as master, and failover to <replaceable>wlan0</replaceable> if
necessary:</para>
<screen>&prompt.root; <userinput>ifconfig <replaceable>lagg0</replaceable> create</userinput>
&prompt.root; <userinput>ifconfig <replaceable>lagg0</replaceable> up laggproto failover laggport <replaceable>bge0</replaceable> laggport <replaceable>wlan0</replaceable></userinput></screen>
<para>The interface will look something like this, the major
differences will be the <acronym>MAC</acronym> address and the
device names:</para>
<screen>&prompt.root; <userinput>ifconfig <replaceable>lagg0</replaceable></userinput>
lagg0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
options=8&lt;VLAN_MTU&gt;
ether 00:21:70:da:ae:37
media: Ethernet autoselect
status: active
laggproto failover
laggport: wlan0 flags=0&lt;&gt;
laggport: bge0 flags=5&lt;MASTER,ACTIVE&gt;</screen>
<para>To avoid having to do this after every reboot, one can add
something like the following lines to the
<filename>/etc/rc.conf</filename> file:</para>
<programlisting>ifconfig_bge0="up"
ifconfig_iwn0="ether 00:21:70:da:ae:37"
wlans_iwn0="wlan0"
ifconfig_wlan0="WPA"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto failover laggport bge0 laggport wlan0 DHCP"
</programlisting>
</example>
</sect2>
</sect1>