FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 12-07-2011, 05:03 PM
Matt Garman
 
Default Static routes with a metric?

Hi,

How can I define static routes to be created at boot time with a specific
metric? I have two NICs that ultimately end up at the same peer, but
literally go through two completely different networks. IOW, each NIC
connects to a different layer 3 device.

Also, note that the machine actually has three total NICs: the third is the
owner of the default route. The two mentioned above are for a specialized
sub net.

What I basically need to be able to do is this:
route add -host h1 gw g1 metric 0
route add -host h1 gw g2 metric 10

Notice that everything is the same except the gateway and metric. I could
put this in /etc/rc.local, but was wondering if there's a cleaner way to do
it in e.g. the network-scripts directory.

Thanks,
Matt
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-07-2011, 05:28 PM
Benjamin Franz
 
Default Static routes with a metric?

On 12/7/2011 10:03 AM, Matt Garman wrote:
> Hi,
>
> [...]
>
> What I basically need to be able to do is this:
> route add -host h1 gw g1 metric 0
> route add -host h1 gw g2 metric 10
>
> Notice that everything is the same except the gateway and metric. I could
> put this in /etc/rc.local, but was wondering if there's a cleaner way to do
> it in e.g. the network-scripts directory.
>

If you create files in the /etc/sysconfig/network-scripts directory
named according to the scheme

route-eth0
route-eth1
route-eth2

it will execute each line in the files as

/sbin/ip route add <line>

when each interface is brought up.

Look in the /etc/sysconfig/network-scripts/ifup-routes script for all
the gory details and features.

--
Benjamin Franz


_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-15-2011, 04:54 PM
Matt Garman
 
Default Static routes with a metric?

Adding additional info for posterity, and in case anyone else runs
across this...

On Wed, Dec 7, 2011 at 12:28 PM, Benjamin Franz <jfranz@freerun.com> wrote:
> On 12/7/2011 10:03 AM, Matt Garman wrote:
>> Hi,
>>
>> [...]
>>
>> What I basically need to be able to do is this:
>> route add -host h1 gw g1 metric 0
>> route add -host h1 gw g2 metric 10
>>
>> Notice that everything is the same except the gateway and metric. I could
>> put this in /etc/rc.local, but was wondering if there's a cleaner way to do
>> it in e.g. the network-scripts directory.
>>
>
> If you create files in the /etc/sysconfig/network-scripts directory
> named according to the scheme
>
> route-eth0
> route-eth1
> route-eth2
>
> it will execute each line in the files as
>
> /sbin/ip route add <line>
>
> when each interface is brought up.
>
> Look in the /etc/sysconfig/network-scripts/ifup-routes script for all
> the gory details and features.

I actually did just that---looked at the ifup-routes script. The
thing that threw me off is the comments about "older format" versus
"new format". I probably read into the comments too much, but I
thought to myself, "I should probably use the new format, as they
might some day deprecate the old format."

But anyway, the "older format" is what I need. With the older format,
it's exactly what you said above: each line corresponds to running "ip
route add <line>". So what I added were lines in this format:

<addr>/<mask> via <gateway> dev <device> metric <N>

A contrived example might be:

10.25.77.0/24 via 192.168.1.1 dev eth0 metric 5

The "new format" is where each group of three lines corresponds to a
route. You have the ADDRESSxx=, NETMASKxx=, GATEWAYxx= lines.
Clearly this is less flexible, particularly if you need to set a
metric like me.

Anyway, hopefully that's useful for anyone in a similar situation!

-Matt
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-17-2011, 03:43 AM
Mike Burger
 
Default Static routes with a metric?

Hi, Matt.

Sorry for the top post, but my iPad mail client seems averse to allowing me to bottom post.

Just wanted to take a moment to note that I believe you've got things a little bit reversed.

The use Of the route-ethX files and the "ip" command are the "newer" method. Setting the NETMASK and ADDRESS in the ifcfg-ethX files has always been and continues to be the norm. Having the GATEWAY field in either the ifcfg-ethX files or in /etc/sysconofig/network is the older way of setting the default route.

You're right, though...it was certainly less flexible. ;-)

On Dec 15, 2011, at 12:54 PM, Matt Garman <matthew.garman@gmail.com> wrote:

> Adding additional info for posterity, and in case anyone else runs
> across this...
>
> On Wed, Dec 7, 2011 at 12:28 PM, Benjamin Franz <jfranz@freerun.com> wrote:
>> On 12/7/2011 10:03 AM, Matt Garman wrote:
>>> Hi,
>>>
>>> [...]
>>> What I basically need to be able to do is this:
>>> route add -host h1 gw g1 metric 0
>>> route add -host h1 gw g2 metric 10
>>>
>>> Notice that everything is the same except the gateway and metric. I could
>>> put this in /etc/rc.local, but was wondering if there's a cleaner way to do
>>> it in e.g. the network-scripts directory."
>>>
>> If you create files in the /etc/sysconfig/network-scripts directory
>> named according to the scheme
>>
>> route-eth0
>> route-eth1
>> route-eth2
>>
>> it will execute each line in the files as
>>
>> /sbin/ip route add <line>
>>
>> when each interface is brought up.
>>
>> Look in the /etc/sysconfig/network-scripts/ifup-routes script for all
>> the gory details and features.
>
> I actually did just that---looked at the ifup-routes script. The
> thing that threw me off is the comments about "older format" versus
> "new format". I probably read into the comments too much, but I
> thought to myself, "I should probably use the new format, as they
> might some day deprecate the old format."
>
> But anyway, the "older format" is what I need. With the older format,
> it's exactly what you said above: each line corresponds to running "ip
> route add <line>". So what I added were lines in this format:
>
> <addr>/<mask> via <gateway> dev <device> metric <N>
>
> A contrived example might be:
>
> 10.25.77.0/24 via 192.168.1.1 dev eth0 metric 5
>
> The "new format" is where each group of three lines corresponds to a
> route. You have the ADDRESSxx=, NETMASKxx=, GATEWAYxx= lines.
> Clearly this is less flexible, particularly if you need to set a
> metric like me.
>
> Anyway, hopefully that's useful for anyone in a similar situation!
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-17-2011, 02:37 PM
Ljubomir Ljubojevic
 
Default Static routes with a metric?

Vreme: 12/17/2011 05:43 AM, Mike Burger piše:
> Hi, Matt.
>
> Sorry for the top post, but my iPad mail client seems averse to allowing me to bottom post.
>
> Just wanted to take a moment to note that I believe you've got things a little bit reversed.
>
> The use Of the route-ethX files and the "ip" command are the "newer" method. Setting the NETMASK and ADDRESS in the ifcfg-ethX files has always been and continues to be the norm. Having the GATEWAY field in either the ifcfg-ethX files or in /etc/sysconofig/network is the older way of setting the default route.
>
> You're right, though...it was certainly less flexible. ;-)
>
> On Dec 15, 2011, at 12:54 PM, Matt Garman<matthew.garman@gmail.com> wrote:
>

No, you got it wrong,

he was talking about that route-ethX, not ifcfg-ethX, supports NETMASK,
ADDRESS, GATEWAY (in separate lines) format. I used it from 2006. You
can add as much routes that way as you please:

NETMASK0=
ADDRESS0=
GATEWAY0=

NETMASK1=
ADDRESS1=
GATEWAY1=

NETMASK2=
ADDRESS2=
GATEWAY2=

...

--

Ljubomir Ljubojevic
(Love is in the Air)
PL Computers
Serbia, Europe

Google is the Mother, Google is the Father, and traceroute is your
trusty Spiderman...
StarOS, Mikrotik and CentOS/RHEL/Linux consultant
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-18-2011, 05:43 AM
"Mike Burger"
 
Default Static routes with a metric?

> Vreme: 12/17/2011 05:43 AM, Mike Burger pi?e:
>> Hi, Matt.
>>
>> Sorry for the top post, but my iPad mail client seems averse to allowing
>> me to bottom post.
>>
>> Just wanted to take a moment to note that I believe you've got things a
>> little bit reversed.
>>
>> The use Of the route-ethX files and the "ip" command are the "newer"
>> method. Setting the NETMASK and ADDRESS in the ifcfg-ethX files has
>> always been and continues to be the norm. Having the GATEWAY field in
>> either the ifcfg-ethX files or in /etc/sysconofig/network is the older
>> way of setting the default route.
>>
>> You're right, though...it was certainly less flexible. ;-)
>>
>> On Dec 15, 2011, at 12:54 PM, Matt Garman<matthew.garman@gmail.com>
>> wrote:
>>
>
> No, you got it wrong,
>
> he was talking about that route-ethX, not ifcfg-ethX, supports NETMASK,
> ADDRESS, GATEWAY (in separate lines) format. I used it from 2006. You
> can add as much routes that way as you please:
>
> NETMASK0=
> ADDRESS0=
> GATEWAY0=
>
> NETMASK1=
> ADDRESS1=
> GATEWAY1=
>
> NETMASK2=
> ADDRESS2=
> GATEWAY2=

Aaahhh...yes, you're right...I did miss that point. Thanks for setting me
straight. :-)

--
Mike Burger
http://www.bubbanfriends.org

Visit the Dog Pound II BBS
telnet://dogpound2.citadel.org or http://dogpound2.citadel.org

To be notified of updates to the web site, visit:

https://www.bubbanfriends.org/mailman/listinfo/site-update

or send a blank email message to:

site-update-subscribe@bubbanfriends.org
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-18-2011, 05:57 AM
"Mike Burger"
 
Default Static routes with a metric?

> Vreme: 12/17/2011 05:43 AM, Mike Burger pi?e:
>> Hi, Matt.
>>
>> Sorry for the top post, but my iPad mail client seems averse to allowing
>> me to bottom post.
>>
>> Just wanted to take a moment to note that I believe you've got things a
>> little bit reversed.
>>
>> The use Of the route-ethX files and the "ip" command are the "newer"
>> method. Setting the NETMASK and ADDRESS in the ifcfg-ethX files has
>> always been and continues to be the norm. Having the GATEWAY field in
>> either the ifcfg-ethX files or in /etc/sysconofig/network is the older
>> way of setting the default route.
>>
>> You're right, though...it was certainly less flexible. ;-)
>>
>> On Dec 15, 2011, at 12:54 PM, Matt Garman<matthew.garman@gmail.com>
>> wrote:
>>
>
> No, you got it wrong,
>
> he was talking about that route-ethX, not ifcfg-ethX, supports NETMASK,
> ADDRESS, GATEWAY (in separate lines) format. I used it from 2006. You
> can add as much routes that way as you please:
>
> NETMASK0=
> ADDRESS0=
> GATEWAY0=
>
> NETMASK1=
> ADDRESS1=
> GATEWAY1=
>
> NETMASK2=
> ADDRESS2=
> GATEWAY2=

Although, thinking back, you've made a very similar point to mine:

That the standard of xxx.xxx.xxx.xxx/yy via zzz.zzz.zzz.zzz style of
entry, invoking the "ip" command, is still the "newer" way of doing it,
while the parameter-per-line method you noted above, just like putting the
data into the ifcfg-ethX and the network files, is an older way of doing
so.

--
Mike Burger
http://www.bubbanfriends.org

Visit the Dog Pound II BBS
telnet://dogpound2.citadel.org or http://dogpound2.citadel.org

To be notified of updates to the web site, visit:

https://www.bubbanfriends.org/mailman/listinfo/site-update

or send a blank email message to:

site-update-subscribe@bubbanfriends.org
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-18-2011, 10:46 AM
Ljubomir Ljubojevic
 
Default Static routes with a metric?

Vreme: 12/18/2011 07:57 AM, Mike Burger piše:
>
> Although, thinking back, you've made a very similar point to mine:
>
> That the standard of xxx.xxx.xxx.xxx/yy via zzz.zzz.zzz.zzz style of
> entry, invoking the "ip" command, is still the "newer" way of doing it,
> while the parameter-per-line method you noted above, just like putting the
> data into the ifcfg-ethX and the network files, is an older way of doing
> so.
>

Depends on how old ip command in route-ethX is. If it is back from 2.4
kernel????

I will not bother to research, and I did not say it was older or newer,
just that there is such convention.

--

Ljubomir Ljubojevic
(Love is in the Air)
PL Computers
Serbia, Europe

Google is the Mother, Google is the Father, and traceroute is your
trusty Spiderman...
StarOS, Mikrotik and CentOS/RHEL/Linux consultant
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 09:44 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org