Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Networking & Security
  • Search

Changing the metric of an interface.

Having problems getting connected to the internet or running a server? Wondering about securing your box? Ask here.
Post Reply
Advanced search
9 posts • Page 1 of 1
Author
Message
bunkacid
Tux's lil' helper
Tux's lil' helper
Posts: 111
Joined: Tue Jan 11, 2005 2:04 am
Location: Laguna Hills, CA
Contact:
Contact bunkacid
Website

Changing the metric of an interface.

  • Quote

Post by bunkacid » Tue Jan 11, 2005 2:25 am

Hi,
I've been stuck on an issue for several weeks now, that is bugging th crap out of me. I've come across an issue when attempting to change the metric of an interface on my laptop. Searching through the gentoo network configuration files, there isn't anywhere to change the metric of an interface. I've also searched google, and have so far come up with no reason or answer as to why it isn't working.

Code: Select all

pmobilex px # ifconfig ath0 metric 2
SIOCSIFMETRIC: Operation not supported
pmobilex px # ifconfig eth0 metric 2
SIOCSIFMETRIC: Operation not supported
I use both interfaces depending on what I am doing, but mostly use the ethernet interface when transfering large files. Currently whenever I plug in the ethernet, I have to down the ath0 interface.

Before I changed over to Gentoo, I was a Debian user, and it was possible to change the metric. Is there a kernel patch that is affecting this?

Any help would be greatly apprieciated
Top
moocha
Watchman
Watchman
Posts: 5722
Joined: Tue Oct 21, 2003 6:45 pm

  • Quote

Post by moocha » Tue Jan 11, 2005 3:28 am

Changing the metric via ifconfig is fundamentally flawed in post-2.2 kernels. Use the ip tool from the iproute2 package.

Code: Select all

ip route add 1.2.3.4/24 via 66.77.88.99 metric 2
or for the default route

Code: Select all

ip route del default
ip route add default via 66.77.88.99 metric 2
You can add the metric specification to routes_eth0 and routes_ath0 in /etc/conf.d/net (provided you use a new enough baselayout and have modules_eth0=("iproute2") of course)
Military Commissions Act of 2006: http://tinyurl.com/jrcto

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety."
-- attributed to Benjamin Franklin
Top
bunkacid
Tux's lil' helper
Tux's lil' helper
Posts: 111
Joined: Tue Jan 11, 2005 2:04 am
Location: Laguna Hills, CA
Contact:
Contact bunkacid
Website

  • Quote

Post by bunkacid » Tue Jan 11, 2005 4:03 am

Thanks for the update on ifconfig being flawed. Something was fishy.
I forgot to mention previously that currently my config files are setup for iproute2, and dhcp. I was using ifconfig to show my struggle.

I use dhcp for both interfaces, which allows easy portability of my laptop between networks.

I'd rather not have to deal with specific routes, but rather the whole interface itself. Sticking specific static routes in my configuration makes things more of a hassle.

Simplicity would be beautiful. Why doesn't there seem to a way to change the metric of the whole interface and not just individual routes?

baselayout 1.11.8
iproute2 2.6.9.20040831
Top
moocha
Watchman
Watchman
Posts: 5722
Joined: Tue Oct 21, 2003 6:45 pm

  • Quote

Post by moocha » Tue Jan 11, 2005 4:23 am

Weeeeellll...
man netdevice wrote:SIOCGIFMETRIC, SIOCSIFMETRIC
Get or set the metric of the device using ifr_metric. This is currently not implemented; it sets ifr_metric to 0 if you attempt to read it and returns EOPNOTSUPP if you attempt to set it.
net/core/dev.c wrote:

Code: Select all

/*
 *      Perform the SIOCxIFxxx calls.
 */
static int dev_ifsioc(struct ifreq *ifr, unsigned int cmd)

<snip>

switch (cmd) {

<snip>

case SIOCSIFMETRIC:     /* Set the metric on the interface
                                           (currently unused) */
                        return -EOPNOTSUPP;
Guess that says it all... It was probably a Debian patch.
Still, I'm very uncomfortable with the idea of the interface metric. The metric is conceptually associated with a specific route. "Default value" type metrics should be handled in userspace, not at kernel level...
Military Commissions Act of 2006: http://tinyurl.com/jrcto

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety."
-- attributed to Benjamin Franklin
Top
bunkacid
Tux's lil' helper
Tux's lil' helper
Posts: 111
Joined: Tue Jan 11, 2005 2:04 am
Location: Laguna Hills, CA
Contact:
Contact bunkacid
Website

  • Quote

Post by bunkacid » Tue Jan 11, 2005 8:33 am

Considering changing the metric of an interface is something that is possible on a Cisco, a Win32 box, and other linux distro's. When I found the metric in the bash-completion in Gentoo, I figured it would have worked. I suppose I'm just a bit of a control freak who got used to a useful feature.

But how else would you be able to roam from the wifi, to the wired lan, without downing an interface and or manualy updating the routes to higher metrics?

I guess more work is needed with the networking scripts to make them smarter. I'm sure there's others who use their laptops in a similar fashion.

I've been digging around more in iproute2.

Code: Select all

 #/etc/conf.d/net
routes_ath0=(
        "192.168.48.0/24 dev ath0 proto kernel scope link metric 2"
        "default dev ath0 metric 2 scope global"
)

routes_eth0=(
        "192.168.48.0/24 dev eth0 proto kernel scope link metric 1"
        "default dev eth0 metric 1 scope global"
)
This seems to set the metric for the device, but I don't like having the static local network route in there and it still doesn't fix the main issue.
It's a shame, the routes_XXX can't delete/change routes only append them. Now if I could just figure out how to include some more functionality, and some special variables, that tells the scripts to re-write the other routes just added by the dhcp clients. Or have them set a default metric when they add the routes.


Oi. Headache.
Top
moocha
Watchman
Watchman
Posts: 5722
Joined: Tue Oct 21, 2003 6:45 pm

  • Quote

Post by moocha » Tue Jan 11, 2005 10:33 pm

bunkacid wrote:Oi. Headache.
Heh :D

Still you have a valid point there - me being a purist is all well but that tends not to help that much with practical issues... Maybe you could remember or figure out what Debian kernel that was? I could then try and take a peek around for the patch and try to integrate it into the gentoo-dev-sources kernel (assuming you're 2.6). Then we could submit it to Bugzilla and perhaps get it into the standard gentoo-dev-sources patchset.
Military Commissions Act of 2006: http://tinyurl.com/jrcto

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety."
-- attributed to Benjamin Franklin
Top
Syntaxis
Guru
Guru
User avatar
Posts: 511
Joined: Sun Apr 28, 2002 10:05 pm
Location: London, UK

  • Quote

Post by Syntaxis » Tue Jan 11, 2005 10:57 pm

bunkacid wrote:Simplicity would be beautiful. Why doesn't there seem to a way to change the metric of the whole interface and not just individual routes?
Is Debian's ifmetric package not what you're looking for?
ifmetric is a Linux tool for setting the metrics of all IPv4 routes attached to a given network interface at once.
The Debian User Forums - help them grow!
Top
bunkacid
Tux's lil' helper
Tux's lil' helper
Posts: 111
Joined: Tue Jan 11, 2005 2:04 am
Location: Laguna Hills, CA
Contact:
Contact bunkacid
Website

  • Quote

Post by bunkacid » Tue Jan 11, 2005 11:11 pm

Hey moocha,

Thanks for the help.

The last Debian kernel I was using was their debian flavored 2.6.7 without any extra patches.
Top
bunkacid
Tux's lil' helper
Tux's lil' helper
Posts: 111
Joined: Tue Jan 11, 2005 2:04 am
Location: Laguna Hills, CA
Contact:
Contact bunkacid
Website

  • Quote

Post by bunkacid » Tue Jan 11, 2005 11:19 pm

Is Debian's ifmetric package not what you're looking for?
ifmetric is a Linux tool for setting the metrics of all IPv4 routes attached to a given network interface at once.
Sounds like a neat tool, but the changes to the metric were made using just "ifconfig ath0 metric 2" in the local boot script while I was using Debian.
Top
Post Reply

9 posts • Page 1 of 1

Return to “Networking & Security”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic