Setting of the redundant Internet connection in openWrt

Modern routers have multiple network interfaces for communication and Internet. As a rule, this connection goes over Ethernet port, Wi-Fi and the mobile Internet using the usb-modem.

While all active network interfaces are connected to the Internet the only one is active always. The word «active» refers to the interface or connection through which the current Internet distribution occurs. Often the «active» channel is the channel that has the greatest capacity, such a channel is the Ethernet connection.

Redundant Internet connection if you have multiple network interfaces is based on the automatic change of channel if there is no connection through the active channel.

In other words, this mechanism should work as follows:
currently the Internet is dealt through the Ethernet port. As soon as the link is lost on this port, the wifi interface should get the status of active channel automatically, and if the connection via wi-fi is lost, the mobile Internet via usb modem gets the status of active channel.

And this mechanism should work in the opposite direction. When the link appears on the Ethernet port, it gets the status of active channel automatically and wi-fi and ppp interfaces should become redundant.

Redundancy of the Internet connection of this kind can be achieved by installing of different metrics for all interfaces. The metrics will play the role of priorities. Then for the above described scheme the metrics should be assigned as follows:
the highest priority for the Ethernet interface - metric 1.
medium priority for the interface wi-fi - metric 2.
the lowest priority for the ppp interface - metric 3.

Then the routing schedule will have three default routes, the active status will always have the route with the lowest metric. The routing schedule will look as follows:


Redundancy setting in openWrt is a matter of editing the file /etc/config/network. The file for this case would looks like the following:

config interface 'lan1' 
	option ifname 'lan1' 
	option proto 'dhcp' 
	option metric '1' 

config interface 'wlan0' 
	option ifname 'wlan0' 
	option proto 'dhcp' 
	option metric '2' 

config interface 'wan' 
	option proto '3g' 
	option device '/dev/ttyUSB4' 
	option service 'umts' 
	option username 'mts' 
	option password 'mts' 
	option apn 'inetrnet.mts.ru' 
	option type 'static' 
	option metric '3'