Modify

Opened 6 years ago

Last modified 4 years ago

#10423 reopened defect

Static route removed during ifup from another face

Reported by: jeroen.louwes@… Owned by: developers
Priority: normal Milestone: Netifd Implementation
Component: base system Version: Trunk
Keywords: network Cc:

Description

I have two WAN interfaces, each configured by DHCP. I have set one interface with metric 10 and the other metric 20.

When the first interface comes up a default route with metric 10 is configured, but when the second interface comes up the default route is removed and replaced by the second interface default route.

In my opinion this should not be replaced, but added. Only remove static if it is really from that interface. I really need it for my mwan script.

Extra info

/etc/config/network
...
config 'interface' 'isp1'
	option 'ifname' 'eth0.1'
	option 'proto' 'dhcp'
	option 'metric' '10'
	option 'dns' '208.67.222.222 8.8.8.8'

config 'interface' 'isp2'
	option 'ifname' 'eth0.2'
	option 'proto' 'dhcp'
	option 'metric' '20'
	option 'dns' '208.67.220.220 8.8.4.4'
...

Attachments (0)

Change History (10)

comment:1 Changed 6 years ago by anonymous

The cause of the problem is the /usr/share/udhcpc/default.script script at line 72 till 75. These lines cause all default routes (except for the one just set) to be deleted. I think it should only delete default routes with the same metric as the one just set, leaving all other default routes with other metrics intact.

For the time being i commented those 4 lines out.

comment:2 Changed 6 years ago by anonymous

Changing line 72 in /usr/share/udhcpc/default.script from

eval $(route -n | awk '

to

eval $(route -n | awk '$5 == ('${user_metric:-0}')' | awk '

should do the trick.

udhcpc will then only remove static default route if it has the same metric as the new default route just set . Please review for adoption in trunk.

Thank you !

comment:3 Changed 6 years ago by nbd

  • Milestone changed from Attitude Adjustment (trunk) to Netifd Implementation

comment:4 Changed 6 years ago by nbd

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

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

comment:5 Changed 5 years ago by andee@…

What is the status of this? I'm using Attitude Adjustment r34185 and I am also experiencing this issue.

comment:6 follow-up: Changed 5 years ago by anonymous

I'm on r33883, Attitude Adjustment 12.09-beta2

Setting metric option for (DHCP) WAN interfaces (/etc/config/network) do solve the issue. Letting you keep default route entries for both interfaces.

Without it - bringing up either of them will delete the default route for the other ( #ifup wan / # ifup wan2 )

comment:7 in reply to: ↑ 6 Changed 5 years ago by anonymous

Replying to anonymous:

I'm on r33883, Attitude Adjustment 12.09-beta2

Setting metric option for (DHCP) WAN interfaces (/etc/config/network) do solve the issue. Letting you keep default route entries for both interfaces.

Without it - bringing up either of them will delete the default route for the other ( #ifup wan / # ifup wan2 )

leaving /usr/share/udhcpc/default.script untouched.

comment:8 follow-up: Changed 4 years ago by LandRocket

  • Resolution fixed deleted
  • Status changed from closed to reopened

Same problem as above, except one interface is DHCP, other is PPPoE...., running Barrier Breaker (Bleeding Edge, r37816)

From /etc/config/network.....

config interface 'wan1'

option ifname 'eth1'
option metric '1'
option proto 'dhcp'

config interface 'wan2'

option ifname 'eth0.2'
option metric '2'
option proto 'pppoe'
option username 'usernamedeleted'
option password 'passworddeleted'

On first bootup, I get the 2 default routes:

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 x.x.x.x 0.0.0.0 UG 1 0 0 eth1
0.0.0.0 y.y.y.y 0.0.0.0 UG 2 0 0 pppoe-wan2
x.x.x.x 0.0.0.0 255.255.254.0 U 1 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan
y.y.y.y 0.0.0.0 255.255.255.255 UH 0 0 0 pppoe-wan2

Unfortunately, WAN1 DHCP renews every 900 seconds (the non-PPPoE link/eth1), so after 15mins, logread | grep wan1 gives me:

Thu Jan 1 00:00:33 1970 daemon.error netifd: wan1 (827): Sending select for x.x.x.x...
Thu Jan 1 00:00:34 1970 daemon.error netifd: wan1 (827): Lease of x.x.x.x obtained, lease time 900
Thu Jan 1 00:00:34 1970 daemon.error netifd: Interface 'wan1' is now up
Wed Aug 21 14:19:29 2013 daemon.error netifd: wan1 (827): Sending renew...
Wed Aug 21 14:19:30 2013 daemon.error netifd: wan1 (827): Lease of x.x.x.x obtained, lease time 900

and sure enough, route has gone:

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 y.y.y.y 0.0.0.0 UG 2 0 0 pppoe-wan2
x.x.x.x 0.0.0.0 255.255.254.0 U 1 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan
y.y.y.y 0.0.0.0 255.255.255.255 UH 0 0 0 pppoe-wan2

comment:9 in reply to: ↑ 8 Changed 4 years ago by anonymous

Replying to LandRocket:

Same problem as above, except one interface is DHCP, other is PPPoE...., running Barrier Breaker (Bleeding Edge, r37816)

From /etc/config/network.....

config interface 'wan1'

option ifname 'eth1'
option metric '1'
option proto 'dhcp'

config interface 'wan2'

option ifname 'eth0.2'
option metric '2'
option proto 'pppoe'
option username 'usernamedeleted'
option password 'passworddeleted'

On first bootup, I get the 2 default routes:

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 x.x.x.x 0.0.0.0 UG 1 0 0 eth1
0.0.0.0 y.y.y.y 0.0.0.0 UG 2 0 0 pppoe-wan2
x.x.x.x 0.0.0.0 255.255.254.0 U 1 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan
y.y.y.y 0.0.0.0 255.255.255.255 UH 0 0 0 pppoe-wan2

Unfortunately, WAN1 DHCP renews every 900 seconds (the non-PPPoE link/eth1), so after 15mins, logread | grep wan1 gives me:

Thu Jan 1 00:00:33 1970 daemon.error netifd: wan1 (827): Sending select for x.x.x.x...
Thu Jan 1 00:00:34 1970 daemon.error netifd: wan1 (827): Lease of x.x.x.x obtained, lease time 900
Thu Jan 1 00:00:34 1970 daemon.error netifd: Interface 'wan1' is now up
Wed Aug 21 14:19:29 2013 daemon.error netifd: wan1 (827): Sending renew...
Wed Aug 21 14:19:30 2013 daemon.error netifd: wan1 (827): Lease of x.x.x.x obtained, lease time 900

and sure enough, route has gone:

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 y.y.y.y 0.0.0.0 UG 2 0 0 pppoe-wan2
x.x.x.x 0.0.0.0 255.255.254.0 U 1 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan
y.y.y.y 0.0.0.0 255.255.255.255 UH 0 0 0 pppoe-wan2

I have very simillar config and the same issue.
2 WANs - one DHCP and one UMTS/GPRS/EV-DO.
Default route for WAN1 disappears after WAN1 DHCP renew.

Used version: BARRIER BREAKER (Bleeding Edge, r38999)

Was that issue addressed? Is there any workaround for this?

comment:10 Changed 4 years ago by LandRocket

Unfortunately, I don't have the expertise to fix the problem, but I managed to come up with a workaround.

I found from /lib/netifd/dhcp.script that after any DHCP, OpenWrt calls /etc/udhcpc.user

So in /etc/udhcpc.user, I have created the following:

if [ "$1" == "renew" ]; then

if [ "$interface" == "eth1" ]; then

cur=$(route -n | grep eth1 | awk '/UG/{print $2};')
if [ "$cur" != "$i" ]; then

if [ "$cur" != "" ]; then

route del default gw $cur

fi

route add default gw $i metric 1
fi

fi

fi

*NOTE:* metric is hard coded to 1 as I couldn't seem to find a variable/didn't have the knowledge to pull it from config, but I think the script is fairly self explanatory, and should be easy enough to adapt to your own config.

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.