You are not logged in.

#1 2016-12-24 08:11:34

h.safe
Member
Registered: 2016-08-01
Posts: 31

[Resolved]How to change the default route metric

Hi,

I am running into a problem and would like to know a quick fix to that. Currently ip route default GW has got the values:
default via 192.168.10.1 dev eth0 proto static metric 100
default via 192.168.42.129 dev usb0 proto static metric 101

I would like to change the metric value of the usb0 interface temporarily lower than the eth0 to be chosen for the outgoing traffic. How can I achieve this?
Thanks

Last edited by h.safe (2016-12-27 11:59:48)


Why did Bodhidharma come from the west?

Offline

#2 2016-12-24 08:30:09

Into the Pit
Member
Registered: 2010-09-04
Posts: 37

Re: [Resolved]How to change the default route metric

could be easily done with the

ip route

command. see man ip-route for more info.

Offline

#3 2016-12-24 09:21:14

h.safe
Member
Registered: 2016-08-01
Posts: 31

Re: [Resolved]How to change the default route metric

I couldn't and I appreciate you to share that "easily" one line code here ...


Why did Bodhidharma come from the west?

Offline

#4 2016-12-24 13:11:04

seth
Member
Registered: 2012-09-03
Posts: 58,669

Re: [Resolved]How to change the default route metric

How long did you try? Try again, maybe invoke google.
The solution is absolutely straightforward and posting it *will* be embarrassing.

Offline

#5 2016-12-26 05:49:19

h.safe
Member
Registered: 2016-08-01
Posts: 31

Re: [Resolved]How to change the default route metric

Embarrassing is the hollow reply posts that gets people nowhere but a count up for you...try google and immediately will get to know it is not at all a simple straight forward solution to it in Linux boxes and particularly when multiple default routes are in question...


Why did Bodhidharma come from the west?

Offline

#6 2016-12-26 08:40:56

seth
Member
Registered: 2012-09-03
Posts: 58,669

Re: [Resolved]How to change the default route metric

ip route del default via 192.168.42.129 dev usb0 proto static metric 101
ip route add default via 192.168.42.129 dev usb0 proto static metric 99

Do yourself a favor and use a smartphone instead.

Offline

#7 2016-12-26 10:25:55

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [Resolved]How to change the default route metric

There doesn't seem to be a one-liner to change an existing metric, strangely.

In general, I would prefer adding the new route entry *first*, to prevent a short time period where there might be no route (not applicable to this particular example, I know).

Offline

#8 2016-12-26 12:33:06

seth
Member
Registered: 2012-09-03
Posts: 58,669

Re: [Resolved]How to change the default route metric

The one-liner would be "ip route change ..." but it fails on many realtek chips, unfortunately.
You can reverse the calls (add first, then del) - should bear no harm either.

Offline

#9 2016-12-26 12:49:25

ayekat
Member
Registered: 2011-01-17
Posts: 1,611

Re: [Resolved]How to change the default route metric

seth wrote:

The one-liner would be "ip route change ..." but it fails on many realtek chips, unfortunately.

It fails on Intel chips, too. But anyway, why would setting network route metrics be dependent on hardware? Doesn't routing happen in the kernel anyway?


pkgshackscfgblag

Offline

#10 2016-12-26 13:11:53

seth
Member
Registered: 2012-09-03
Posts: 58,669

Re: [Resolved]How to change the default route metric

I've never digged into it but it looks like some ioctl fails due to some blocked(?) rtnetlink socket. I've frankly no idea which causes this, the actual kernel module or its state *might* be relevant.
I recall it to have worked on an intel chip, but this might be just coincidental -  I just checked and fails on a broadcom chip as well. It's probably not HW related at all then.
Software or general kernel bug then.

Offline

#11 2016-12-26 13:27:34

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [Resolved]How to change the default route metric

seth wrote:

The one-liner would be "ip route change ..." but it fails on many realtek chips, unfortunately.

Let's see an actual command that should *work*, from you, rather than insults.

AFAICT, it is not possible to *change* an existing metric, using the "ip" command - which I reckon is a bug with the "ip" command sad

Offline

#12 2016-12-26 13:50:15

seth
Member
Registered: 2012-09-03
Posts: 58,669

Re: [Resolved]How to change the default route metric

I've never promised a one-liner, neither did "Into the Pit", that's h.safe's claim.
And add/remove *does* change this, is straight forward and *very* simple to figure?
You could even shadow ip route change with an alias that does so, so don't jump around on insinuated promises and call me insulting - I said this is trivially easy to figure and it *is* on the first google result and requires nothing but copy + paste magic. The OP didn't ask "why does ip change not work" (for he could have then googled the error and found "use add/del" on the first google result *again*

And what and do you believe would happen to your  routing table when "change" did work? Either you got two routes (add/del) briefely none (del/add) or an atomic action (ie a grand kernel lock).

Offline

#13 2016-12-26 15:36:00

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,193

Re: [Resolved]How to change the default route metric

h.safe wrote:

Embarrassing is the hollow reply posts that gets people nowhere but a count up for you...try google and immediately will get to know it is not at all a simple straight forward solution to it in Linux boxes and particularly when multiple default routes are in question...

https://wiki.archlinux.org/index.php/Co … ther_users
https://wiki.archlinux.org/index.php/Co … _not_flame

Note, this is not based solely on my opinion.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#14 2016-12-27 11:53:51

h.safe
Member
Registered: 2016-08-01
Posts: 31

Re: [Resolved]How to change the default route metric

Hello all,
Thanks everyone on this,
a reminder of the forum name :Newbie Corner...


Why did Bodhidharma come from the west?

Offline

#15 2016-12-27 13:53:22

seth
Member
Registered: 2012-09-03
Posts: 58,669

Re: [Resolved]How to change the default route metric

Yes, and not "customer service".

The problem is not the newbieness, the problem is that you asked, got a good hint where to look, NOT EVEN ONE HOUR later said "i can't, please tell me the exact line" and when being suggested that you should at least *try* for yourself first, because the answer really is so trivial, expressed to be offended to be asked to try google.

This is considered help vampirism and not how things work. You get assistance on learning or figuring things, but don't get your problems solve, because you're simply too lazy to figure yourself. And don't tell me that you got the hint, really tried, failed and asked back - within 50 minutes, while just googling for "ip route change metric" virtually spams the answers in your face.

Had you returned with "tried ip route change but it always says error"  or "i don't understand what the NODE_SPEC in the manpage means", this discussion would have taken an entirely different route.

Offline

Board footer

Powered by FluxBB