Page 1 of 1

[SOLVED] How to set default route permanently?

PostPosted: Jul 22nd, '13, 13:34
by magfan
One of my Mageia systems has six ethernet ports. How can I force Mageia to use always eth0 and eth1 as default routes? On reboot Mageia seems to randomly choose any two ports from eth0, ..., eth5.

Re: How to set default route permanently?

PostPosted: Jul 22nd, '13, 19:10
by doktor5000
You may want to have a look inside /etc/sysconfig/network-scripts/ifup-routes
Seems to be documented in http://wiki.mandriva.com/en/Docs/SysAdm ... tic_Routes

Re: How to set default route permanently?

PostPosted: Jul 25th, '13, 13:57
by magfan
Code: Select all
ADDRESS0=<network address for route 0>
NETMASK0=<netmask for route 0>
GATEWAY0=<gateway address for route 0>


Netmask and gateway I understand. But what is meant by address? The system IP?

Re: How to set default route permanently?

PostPosted: Jul 25th, '13, 14:21
by tom_
if you have six working ethernet ports I guess you have at least 6 IP,
one (or more) for each ethernet port.

Re: How to set default route permanently?

PostPosted: Jul 25th, '13, 14:38
by magfan
Yes, that is true. But each of the six ethernet ports has only one separate IP address and Mageia sets up two default routes while booting. The problem is that I do not know in advance which ports will be choosen. For example, eth0 + eth1 is as likely as eth3 + eth1. Or any other combination. I would like to know wether
Code: Select all
IPADDR=
NETMASK=
GATEWAY=

from ifcfg-eth* is equal to
Code: Select all
ADDRESS0=
NETMASK0=
GATEWAY0=

in route-eth*.

Re: How to set default route permanently?

PostPosted: Jul 25th, '13, 15:24
by tom_
ok, sorry, I didn't understood the question.

looking at the script ifup-routes it seems that the values ADDRESSX NETMASKX GATEWAYX
are used to add a route via the command
Code: Select all
/sbin/ip route add $line

without any check against IPADDR NETMASK GATEWAY,
so you can put in these vars the values you want

Code: Select all
handle_file () {
    . $1
    routenum=0
    while [ "x$(eval echo '$'ADDRESS$routenum)x" != "xx" ]; do
        eval $(ipcalc -p $(eval echo '$'ADDRESS$routenum) $(eval echo '$'NETMASK$routenum))
        line="$(eval echo '$'ADDRESS$routenum)/$PREFIX"
        if [ "x$(eval echo '$'GATEWAY$routenum)x" != "xx" ]; then
            line="$line via $(eval echo '$'GATEWAY$routenum)"
        fi
        line="$line dev $2"
        /sbin/ip route add $line
        routenum=$(($routenum+1))
    done
}