You are not logged in.
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
could be easily done with the
ip route
command. see man ip-route for more info.
Offline
I couldn't and I appreciate you to share that "easily" one line code here ...
Why did Bodhidharma come from the west?
Offline
How long did you try? Try again, maybe invoke google.
The solution is absolutely straightforward and posting it *will* be embarrassing.
Offline
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
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
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
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
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?
Offline
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
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
Offline
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
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
Online
Hello all,
Thanks everyone on this,
a reminder of the forum name :Newbie Corner...
Why did Bodhidharma come from the west?
Offline
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