Modify

Opened 7 years ago

Last modified 4 years ago

#8660 reopened defect

dhcp destroys other defaults route

Reported by: matteo.pillon@… Owned by: jow
Priority: normal Milestone: Chaos Calmer 15.05
Component: base system Version: Trunk
Keywords: Cc:

Description

Hi.

On openwrt I setup two wan providers, one with a static route and the other with dhcp.
They have different metrics in order to get an automatic fallback.

[file /etc/config/network]
config 'interface' 'provider1'

option 'proto' 'dhcp'
option 'ifname' 'eth0.1'
option 'metric' '5'

config 'interface' 'provider2'

option 'proto' 'static'
option 'ifname' 'eth0.2'
option 'ipaddr' 'x.x.x.x'
option 'netmask' 'x.x.x.x'
option 'gateway' 'x.x.x.x'
option 'peerdns' '0'
option 'dns' 'x.x.x.x x.x.x.x'
option 'metric' '10'

[-------------------]

But when provider1 gets an ip address, the default route for provider2 gets deleted.
I traced the problem to live in /usr/share/udhcpc/default.script, just removing these lines the route for provider2 stays in place.

[removed lines in /usr/share/udhcpc/default.script]

eval $(route -n | awk '

/0.0.0.0\W{9}('$valid_gw')\W/ {next}
/
0.0.0.0/ {print "route del -net "$1" gw "$2";"}

')

[--------------------------------------]

Why this script needs to remove routes with lower priority than the valid ones added by udhcpc?
Maybe if it crashed? But this way we remove also valid backup routes...

Attachments (0)

Change History (8)

comment:1 in reply to: ↑ description Changed 7 years ago by anonymous

Sorry, wrong formatting

Hi.

On openwrt I setup two wan providers, one with a static route and the other with dhcp.
They have different metrics in order to get an automatic fallback.

[file /etc/config/network]
config 'interface' 'provider1'
	option 'proto' 'dhcp'
	option 'ifname' 'eth0.1'
	option 'metric' '5'
config 'interface' 'provider2'
	option 'proto' 'static'
	option 'ifname' 'eth0.2'
	option 'ipaddr' 'x.x.x.x'
	option 'netmask' 'x.x.x.x'
	option 'gateway' 'x.x.x.x'
	option 'peerdns' '0'
	option 'dns' 'x.x.x.x x.x.x.x'
	option 'metric' '10'
[-------------------]

But when provider1 gets an ip address, the default route for provider2 gets deleted.
I traced the problem to live in /usr/share/udhcpc/default.script, just removing these lines the route for provider2 stays in place.

[removed lines in /usr/share/udhcpc/default.script]
		eval $(route -n | awk '
			/^0.0.0.0\W{9}('$valid_gw')\W/ {next}
			/^0.0.0.0/ {print "route del -net "$1" gw "$2";"}
		')
[--------------------------------------]

Why this script needs to remove routes with lower priority than the valid ones added by udhcpc?
Maybe if it crashed? But this way we remove also valid backup routes...

comment:2 Changed 7 years ago by anonymous

For multiple WAN connections you should use the multiwan package.

comment:3 Changed 7 years ago by jow

This route delete code was written before interface metrics got introduced.
I think it is okay to run the route delete only if all metrics are 0.

comment:4 Changed 7 years ago by jow

  • Owner changed from developers to jow
  • Status changed from new to accepted

comment:5 Changed 7 years ago by Daniel

Why just simply only remove default routes on the interface udchpc is running on:

--- /usr/share/udhcpc/default.script_BACKFIRE_10.03.1-rc4	Thu Nov 18 06:58:44 2010
+++ /usr/share/udhcpc/default.script	Fri Nov 19 19:34:43 2010
@@ -59,6 +59,7 @@
 		
 		eval $(route -n | awk '
 			/^0.0.0.0\W{9}('$valid_gw')\W/ {next}
+			/^0.0.0.0\W.*\W'$interface'$/ &&
 			/^0.0.0.0/ {print "route del -net "$1" gw "$2";"}
 		')

BTW: It does make sense to remove default-routes for DHCP. It is possible that an ISP decides to put his clients on completely new subnets resulting in not only new IP-addresses, but in a new gateway as well...

comment:6 Changed 6 years ago by nbd

  • Resolution set to fixed
  • Status changed from accepted to closed

the metric option now works with netifd when configuring it in the config interface section.

comment:7 Changed 4 years ago by Xaos

  • Resolution fixed deleted
  • Status changed from closed to reopened

Working on current trunk and this has reverted back to deleting routes. I can manually make the change above that was suggested 3 years ago by Daniel and behavior goes back to being sane.

comment:8 Changed 4 years ago by jow

  • Milestone changed from Backfire 10.03.2 to Chaos Calmer (trunk)

Milestone Backfire 10.03.2 deleted

Add Comment

Modify Ticket

Action
as reopened .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.