Opened 3 years ago

Last modified 3 years ago

#18357 new defect

Adding a source to a static route doesn't work

Reported by: peterv@… Owned by: developers
Priority: normal Milestone:
Component: packages Version: Trunk
Keywords: Cc:


Adding a source option to a static route in /etc/config/network results in the route being added, but without the source. For example, adding

    config route 'myroute'
        option interface 'wan'
        option target ''
        option source ''

results in

# ip route show
... dev br-wan  proto static  scope link 

Note that there's no 'src' in that line.

Attachments (1)

netifd.patch (3.8 KB) - added by peterv 3 years ago.
Patch for adding prefsource option for routes

Download all attachments as: .zip

Change History (4)

comment:1 Changed 3 years ago by peterv@…

So this looks like either a bug in netifd or a missing feature and bad documentation. netifd uses the source option to set a routing message attibute of type RTA_SRC (see;a=blob;f=system-linux.c;h=02574fcbeea6f5ab77ad0493c0ccb7d3840d9366;hb=HEAD#l1404). The documentation claims that the source option sets the "preferred source address when sending to destinations covered by the target" (see, but that means netifd should set a routing message attribute of type RTA_PREFSRC. The intention in netifd certainly seems to be to enable source-based routing through the source option (see the comment at;a=blob;f=interface-ip.c;h=6659f8bac16dc0a3ad974250103e0201e7272034;hb=HEAD#l338), so maybe it makes more sense to add a new option for the preferred source?

Changed 3 years ago by peterv

Patch for adding prefsource option for routes

comment:2 Changed 3 years ago by peterv

I'm using the attached patch to set a preferred source on some of my routes. Note that I'm not sure the changes in interface_update_proto_route and interface_ip_dump_route_list are needed.

Add Comment

Modify Ticket

as new .

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

Note: See TracTickets for help on using tickets.