i have a board with linux-3.20 and it have 4G modules. when i startup i can run "pppd call quectel-ppp &" get a ppp0 interface.i also have eth0/eth1 interface,eth0 can connect to the Internet,now i want connect to the Internet by eth0(priority) or ppp0,my route show

Destination Gateway Genmask Flags Metric Ref Use Iface U 0 0 0 eth0 UG 0 0 0 eth1 UH 0 0 0 ppp0 U 0 0 0 eth1 U 0 0 0 eth0

now if i want use eth0 connect to the Internet, i should execute route del -net netmask dev eth0 and route add -net netmask gw dev eth0 , if i want use ppp0,i should execute route del default and route add default dev ppp0

so i create a shell script

while true do #eth0 can ping,use eth0 route del -net netmask dev eth0 route add -net netmask gw dev eth0 ping -c 1 -w1 -I eth0 unix.stackexchange.com if [[ $? != 0 ]];then #eth0 error,use ppp0 if ppp0 up if ifconfig |grep ppp0;then route del default route add default dev ppp0 fi fi sleep 10; done

it does work,but it will make net pack lose a lot also,so can i create route table with connect the internet by eth0 priority and ppp0 second(if eth0 not link or eth0 cant connect internet) automatic?

  • That's a FAQ. No, you cannot. See other variants of this question for more detail. – dirkt Aug 10 at 11:32

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.