LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-14-2007, 08:30 PM   #1
Calab
Member
 
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 60

Rep: Reputation: 2
Question Setting metric for eth interfaces?


I have three ethernet ports on my Debian etch 4.0r1 system.

eth0 is a 100mb port, connected directly to a cable modem @ 5mb/512kb and is dedicated to bittorrent transfers. I'd like this to be the lowest priority with a metric of 30. rtorrent is bound to this interface only.


eth1 is a 1000mb port, connected to the rest of my LAN through a gigabit switch, and to a router fed by another cable modem @ 7mb/1mb. I'd like only LAN traffic to flow through this interface. I'd like this as the middle priority with a metric of 20.


eth2 is a usb connection directly connected to the second cable modem. This port runs an FTP server and my SSH connections. I'd prefer all unbound internet traffic to use this interface and not use eth0 or eth1 by setting a metric of 10.

Is this possible?
 
Old 10-15-2007, 07:06 AM   #2
jmfv
LQ Newbie
 
Registered: Nov 2006
Distribution: Debian Stable
Posts: 17

Rep: Reputation: 1
Have you tried ifmetric?

http://0pointer.de/lennart/projects/ifmetric/
 
Old 10-15-2007, 08:51 AM   #3
Gryyphyn
Member
 
Registered: Dec 2006
Location: Ogden, UT (Go OALUG!)
Distribution: OpenSuSE 10.1
Posts: 61

Rep: Reputation: 15
Cool How to set a metric

As root issue the following:

ifconfig eth0 metric 30 && ifconfig eth1 metric 20 && ifconfig eth2 metric 10

If that doesn't work remove the && and issue each command separately. Also, if you want all torrent traffic going only through eth0, LAN only going through eth1 and everything else through eth2 you may want to set up something like IPTables to do port forwarding specific to those services. Otherwise you may be getting traffic going through the interfaces you don't want it to go through. For help with that you'll need to get with someone else.

Gryyphyn, out.
 
Old 10-16-2007, 01:47 PM   #4
dpajares
LQ Newbie
 
Registered: Apr 2004
Location: uruguay
Distribution: debian
Posts: 26
Blog Entries: 1

Rep: Reputation: 15
Exclamation

Quote:
Originally Posted by Gryyphyn View Post
As root issue the following:

ifconfig eth0 metric 30 && ifconfig eth1 metric 20 && ifconfig eth2 metric 10

If that doesn't work remove the && and issue each command separately. Also, if you want all torrent traffic going only through eth0, LAN only going through eth1 and everything else through eth2 you may want to set up something like IPTables to do port forwarding specific to those services. Otherwise you may be getting traffic going through the interfaces you don't want it to go through. For help with that you'll need to get with someone else.

Gryyphyn, out.
If you specify [whit a diagram] what port and interfaces you need to setup, we can help you with the iptables configuration.

regards, Damián.
 
Old 10-16-2007, 03:36 PM   #5
Calab
Member
 
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 60

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by dpajares View Post
If you specify [whit a diagram] what port and interfaces you need to setup, we can help you with the iptables configuration.
Here's a quick sketch of our configuration... The machine in question is the debian laptop.

http://members.shaw.ca/linkto/temp/NetDiagram.gif (150kB)
 
Old 10-16-2007, 04:26 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
i don't really see how base level if metrics are really going to help you here. Have you come from a point where you believe that changing the metrics will make it act as you expect?

I'd suggest having a look at latrc.org to cover some details...

for eth0 that's for local traffic, so that's just a local subnet without any routing involved. so there's nothign special to do there at all.

for differentiating bittorrent from other internet traffic on your server (it's not really a laptop is it??) then you would presumably just want to return traffic to the route on the nic it came in on. I've not been in the situation where I've done this myself, but there are plenty of examples, such as this doc... http://tetro.net/misc/multilink.html in addition to lartc.org which covers things like the iptables mark module to send traffic back the way it came, or to mark based on port numbers if you are looking at outbound traffic.
 
Old 10-16-2007, 04:59 PM   #7
Calab
Member
 
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 60

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by acid_kewpie View Post
i don't really see how base level if metrics are really going to help you here. Have you come from a point where you believe that changing the metrics will make it act as you expect?
It's more a "preventative" step than something I strictly need to enforce.

When I'm on the Debian machine and surfing, etc, I want traffic to go out via eth2 and is not impacted by torrent traffic on eth0... Unless eth2 happens to be down.

Quote:
Originally Posted by acid_kewpie View Post
for eth0 that's for local traffic, so that's just a local subnet without any routing involved. so there's nothign special to do there at all.
Actually that's eth1... I forgot to label the connections on the diagrams.
(1) - eth0 - Bittorrent traffic
(2) - eth2 - USB connection for FTP server, pasv and sshe
(4) - eth1 - gig PCMICA card, file sharing, ssh, webmin

And, yes, it's a laptop. 1Ghz P3 with 512meg of memory. It's quiet, low power and has it's own battery backup. The ONLY problem I have with it is that the USB ports are only 1.1. I've got a USB 2 PCMICIA card installed, as well as a gigabit LAN PCMCIA card. Before I added the USB2 ports, I had 900gigs connected to it through the USB 1 ports.

It's not something thats urgent, or even important. It's just odd that Linux doesn't support the metric parameter.
 
Old 10-16-2007, 05:25 PM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
it does support it, why did you think it didn't? just check the ifconfig manpages. i just don't see how a basic metric setting is actually going to help you here.
 
Old 10-16-2007, 06:08 PM   #9
Calab
Member
 
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 60

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by acid_kewpie View Post
it does support it, why did you think it didn't? just check the ifconfig manpages. i just don't see how a basic metric setting is actually going to help you here.
Hrm... I'm sure I received a "Parameter not supported" (or something similar) when I tried to apply a metric.

I also updated the interfaces file, but all metrics still appear as 1 when I run ipconfig.

Like I said, it's not a big deal. More for my edification than anything.
 
Old 10-17-2007, 08:03 AM   #10
Gryyphyn
Member
 
Registered: Dec 2006
Location: Ogden, UT (Go OALUG!)
Distribution: OpenSuSE 10.1
Posts: 61

Rep: Reputation: 15
Quote:
Originally Posted by SimpleSimon View Post
Hrm... I'm sure I received a "Parameter not supported" (or something similar) when I tried to apply a metric.

I also updated the interfaces file, but all metrics still appear as 1 when I run ipconfig.

Like I said, it's not a big deal. More for my edification than anything.
First, it does support different metrics by interface. Second this would be useful for traffic shaping to ensure that specific traffic is routed to the correct interface, but more so if you're using the laptop as a router. The outbound traffic will be going to the correct interface by metric but inbound requests won't be unless you have your router set up to direct traffic correctly or you're accessing by specific IP remotely to come in that USB interface. And third the command has to be ifconfig, not ipconfig, and there may be some problems with the metric flag I provided earlier, though I use it quite frequently when experimenting. When in doubt use man pages. man ifconfig

Gryyphyn, out.
 
Old 10-17-2007, 10:52 AM   #11
Calab
Member
 
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 60

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by Gryyphyn View Post
And third the command has to be ifconfig, not ipconfig, and there may be some problems with the metric flag I provided earlier, though I use it quite frequently when experimenting. When in doubt use man pages. man ifconfig
Gryyphyn, out.
My bad... just a typo. I did mean ifconfig.

This is what happens when I try to apply a metric to an interface:

root@debian:/home/steve #ifconfig eth0 metric 30
SIOCSIFMETRIC: Operation not supported

Like I said before, it's not a major issue.
 
Old 10-18-2007, 03:35 AM   #12
jmfv
LQ Newbie
 
Registered: Nov 2006
Distribution: Debian Stable
Posts: 17

Rep: Reputation: 1
Hello

Ifmetric package is what you need. Try

Code:
root@debian:/home/steve #ifmetric eth0 30
root@debian:/home/steve #ifmetric eth1 20
root@debian:/home/steve #ifmetric eth2 10
You can also define the metric in /etc/network/interfaces using the following
Code:
iface eth0 inet dhcp
       up ifmetric eth0 30

iface eth1 inet dhcp
       up ifmetric eth1 20

iface eth2 inet dhcp
       up ifmetric eth2 10
Cheers

Last edited by jmfv; 10-18-2007 at 03:37 AM.
 
Old 10-18-2007, 04:11 AM   #13
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
no it's not what he needs. it what he asked for, and what you've already recommended once, but it is not going to actually provide the result being sought.
 
Old 10-18-2007, 08:16 AM   #14
Gryyphyn
Member
 
Registered: Dec 2006
Location: Ogden, UT (Go OALUG!)
Distribution: OpenSuSE 10.1
Posts: 61

Rep: Reputation: 15
Quote:
Originally Posted by SimpleSimon View Post
My bad... just a typo. I did mean ifconfig.

This is what happens when I try to apply a metric to an interface:

root@debian:/home/steve #ifconfig eth0 metric 30
SIOCSIFMETRIC: Operation not supported

Like I said before, it's not a major issue.
Have you checked to see that you're running the most updated network packages? That's the only thing that I can think would help you set the metrics. It's also possible that the card, any of them, may not support metrics. I can almost completely guarantee that the gig card will. I'm not sure that the usb will. Whether or not your 10/100 nic will is dependent on the chipset.

Check the capabilities on each of the interfaces you're using for network. I'd suggest going to the card manufacturuer/chipset manufacturer to see what they're capable of. I've never seen that error before on anything but the old 10Mb/s cards.

Gryyphyn, out.
 
Old 12-01-2015, 12:14 PM   #15
CoreyJJohnson
LQ Newbie
 
Registered: Dec 2015
Location: MN
Distribution: Whatever is closest
Posts: 2

Rep: Reputation: Disabled
Metrics are attributes for choosing routes

I just re-read your question a few times... Routes are chosen first by most to least specific, before metric. the traffic destination will make your routing decision before metrics have a chance to get involved. If you haven't gotten an answer or are still curious, send your "ifconfig" and "route -v" output, along with a description of the addressing schemes of your networks (no public IP addresses please). Then we can specifically address your desired outcome.


I was struggling with the same routing metric problem that you posted.

I started thinking about it from a routing perspective instead of an interface perspective (Metrics define routes, not interfaces) and got an answer from another user. I will put a link in after I post this first post.

His answer solved my issues. I didn't realize that invoking the ifconfig command doesn't affect routing table entries until I read it. (Then I felt like a noob for thinking like a server engineer instead of a network engineer)

man ifconfig shows the following line:
" metric N This parameter sets the interface metric. It is not available under GNU/Linux."

Again, I didn't care as much about the interface but the metric of the route for the destination traffic.

The route command will allow you to specify an interface but it is not necessary. This may be useful if you had multiple interfaces with different addresses in the same broadcast domain. I have only run into this when lazily setting up home wireless/wired networks....

Here is my cli output progression using the route command. My goal was to change the default gateway to be over my wireless adapter (eth1) but still have local connectivity for my wired adapter (eth0). The third route addition was not necessary for solving my problem but shows that you can specify the interface.

Code:
builder@T42-Ub:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.1.2        0.0.0.0         UG    0      0        0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U     2      0        0 eth1
10.0.1.0        0.0.0.0         255.255.255.0   U     1      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
builder@T42-Ub:~$ sudo route add -net default gw 10.0.0.1 metric 0
[sudo] password for builder:
builder@T42-Ub:~$
builder@T42-Ub:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.1        0.0.0.0         UG    0      0        0 eth1
0.0.0.0         10.0.1.2        0.0.0.0         UG    0      0        0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U     2      0        0 eth1
10.0.1.0        0.0.0.0         255.255.255.0   U     1      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
builder@T42-Ub:~$
builder@T42-Ub:~$ sudo route del -net default gw 10.0.1.2
builder@T42-Ub:~$
builder@T42-Ub:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.1        0.0.0.0         UG    0      0        0 eth1
10.0.0.0        0.0.0.0         255.255.255.0   U     2      0        0 eth1
10.0.1.0        0.0.0.0         255.255.255.0   U     1      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
builder@T42-Ub:~$
builder@T42-Ub:~$ sudo route add -net default gw 10.0.1.2 dev eth0 metric 50
builder@T42-Ub:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.1        0.0.0.0         UG    0      0        0 eth1
0.0.0.0         10.0.1.2        0.0.0.0         UG    50     0        0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U     2      0        0 eth1
10.0.1.0        0.0.0.0         255.255.255.0   U     1      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
builder@T42-Ub:~$

Last edited by CoreyJJohnson; 12-01-2015 at 12:32 PM. Reason: better understanding of question from original posting
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
setting up a wireless router using eth.cable?? nikoz Linux - Wireless Networking 2 02-04-2007 02:00 PM
eth interfaces drop after a while agreenwood Slackware 2 01-31-2006 02:27 PM
Setting up another eth card, to be used for a Router slacker101 Linux - Networking 1 06-21-2005 12:47 AM
configuring eth interfaces problem cranium2004 Linux - Networking 5 04-07-2005 07:55 AM
Two eth interfaces, but one only with internet... Creak Linux - Networking 6 03-12-2005 02:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration