Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
10-14-2007, 08:30 PM
|
#1
|
Member
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 60
Rep:
|
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?
|
|
|
10-15-2007, 07:06 AM
|
#2
|
LQ Newbie
Registered: Nov 2006
Distribution: Debian Stable
Posts: 17
Rep:
|
|
|
|
10-15-2007, 08:51 AM
|
#3
|
Member
Registered: Dec 2006
Location: Ogden, UT (Go OALUG!)
Distribution: OpenSuSE 10.1
Posts: 61
Rep:
|
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.
|
|
|
10-16-2007, 01:47 PM
|
#4
|
LQ Newbie
Registered: Apr 2004
Location: uruguay
Distribution: debian
Posts: 26
Rep:
|
Quote:
Originally Posted by Gryyphyn
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.
|
|
|
10-16-2007, 03:36 PM
|
#5
|
Member
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 60
Original Poster
Rep:
|
Quote:
Originally Posted by dpajares
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)
|
|
|
10-16-2007, 04:26 PM
|
#6
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
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.
|
|
|
10-16-2007, 04:59 PM
|
#7
|
Member
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 60
Original Poster
Rep:
|
Quote:
Originally Posted by acid_kewpie
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
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.
|
|
|
10-16-2007, 05:25 PM
|
#8
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
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.
|
|
|
10-16-2007, 06:08 PM
|
#9
|
Member
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 60
Original Poster
Rep:
|
Quote:
Originally Posted by acid_kewpie
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.
|
|
|
10-17-2007, 08:03 AM
|
#10
|
Member
Registered: Dec 2006
Location: Ogden, UT (Go OALUG!)
Distribution: OpenSuSE 10.1
Posts: 61
Rep:
|
Quote:
Originally Posted by SimpleSimon
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.
|
|
|
10-17-2007, 10:52 AM
|
#11
|
Member
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 60
Original Poster
Rep:
|
Quote:
Originally Posted by Gryyphyn
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.
|
|
|
10-18-2007, 03:35 AM
|
#12
|
LQ Newbie
Registered: Nov 2006
Distribution: Debian Stable
Posts: 17
Rep:
|
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.
|
|
|
10-18-2007, 04:11 AM
|
#13
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
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.
|
|
|
10-18-2007, 08:16 AM
|
#14
|
Member
Registered: Dec 2006
Location: Ogden, UT (Go OALUG!)
Distribution: OpenSuSE 10.1
Posts: 61
Rep:
|
Quote:
Originally Posted by SimpleSimon
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.
|
|
|
12-01-2015, 12:14 PM
|
#15
|
LQ Newbie
Registered: Dec 2015
Location: MN
Distribution: Whatever is closest
Posts: 2
Rep: 
|
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
|
|
|
All times are GMT -5. The time now is 02:55 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|