FS#18700 - [netcfg] add static routes support

Attached to Project: Arch Linux
Opened by Olivier Mehani (shtrom) - Tuesday, 16 March 2010, 03:09 GMT
Last edited by Rémy Oudompheng (remyoudompheng) - Sunday, 29 May 2011, 07:40 GMT
Task Type Feature Request
Category Arch Projects
Status Closed
Assigned To Thomas Bächler (brain0)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

It may be useful to be able to define static routes within netcfg.

Considering the migration to iproute2, the additional syntax could be as simple as
ROUTES=("192.168.1.0/24 via 192.168.0.1" "192.168.2.0/24 via 192.168.0.2")

which would translate as commands
ip route add 192.168.1.0/24 via 192.168.0.1 dev $INTERFACE
ip route add 192.168.2.0/24 via 192.168.0.2 dev $INTERFACE

(This assumes that network 192.168.0.0/24 is reachable via $INTERFACE, which is currently being configured)

Similarly for IPv6 (see  FS#18699 ),
ROUTES=("2001:DB8:1::/64 via 2001:DB8:1::1")
would translate to
ip -6 route add 2001:DB8:1::/64 via 2001:DB8:1::1 dev $INTERFACE
This task depends upon

Closed by  Rémy Oudompheng (remyoudompheng)
Sunday, 29 May 2011, 07:40 GMT
Reason for closing:  Implemented
Additional comments about closing:  Merged in git except that it will only happen if IP='static'
Comment by Olivier Mehani (shtrom) - Tuesday, 16 March 2010, 03:10 GMT
Typo: instead of
ROUTES=("2001:DB8:1::/64 via 2001:DB8:1::1")
I meant
ROUTES6=...
for coherence.
Comment by Olivier Mehani (shtrom) - Tuesday, 16 March 2010, 04:02 GMT
Oh well. It is as fast to code it myself (;

This patch adds netcfg configuration option "ROUTES" to setup static routes. This is done
regardless of whether the IP address is configured using a DHCP or statically.
ROUTES is an array containing entries of the form "DESTINATION[/NETMASK] [via
ROUTER]" which are directly used in an “ip route add” command.
Comment by Olivier Mehani (shtrom) - Tuesday, 16 March 2010, 08:29 GMT
First, a small correction of the previous patch.

Then, the IPv6 version. I realise after looking at the code that this could have been done using the IPCFG (and IP6CFG from  FS#18699 ) parameter, and this proposal is just a generalisation of the GATEWAY parameter. Anyway, here is the code.

Please excuse me for the mess with the order of the patches.

Loading...