[SOLVED] How to set default route permanently?

[SOLVED] How to set default route permanently?

Postby magfan » Jul 22nd, '13, 13:34

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.
Last edited by magfan on Aug 14th, '13, 15:15, edited 1 time in total.
magfan
 
Posts: 334
Joined: Apr 3rd, '12, 12:33

Re: How to set default route permanently?

Postby doktor5000 » Jul 22nd, '13, 19:10

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
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18045
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: How to set default route permanently?

Postby magfan » Jul 25th, '13, 13:57

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?
magfan
 
Posts: 334
Joined: Apr 3rd, '12, 12:33

Re: How to set default route permanently?

Postby tom_ » Jul 25th, '13, 14:21

if you have six working ethernet ports I guess you have at least 6 IP,
one (or more) for each ethernet port.
tom_
 
Posts: 423
Joined: Sep 3rd, '11, 12:26
Location: Porto Ercole, Italy

Re: How to set default route permanently?

Postby magfan » Jul 25th, '13, 14:38

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*.
magfan
 
Posts: 334
Joined: Apr 3rd, '12, 12:33

Re: How to set default route permanently?

Postby tom_ » Jul 25th, '13, 15:24

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
}
tom_
 
Posts: 423
Joined: Sep 3rd, '11, 12:26
Location: Porto Ercole, Italy


Return to Networking

Who is online

Users browsing this forum: No registered users and 1 guest

cron