Logo 
Search:

Unix / Linux / Ubuntu Forum

Ask Question   UnAnswered
Home » Forum » Unix / Linux / Ubuntu       RSS Feeds

2 NICs & howto set metric

  Date: Dec 18    Category: Unix / Linux / Ubuntu    Views: 491
  

I have a thinkpad T20 with latest Ubuntu 8.04. This machine has 2
NICs and I would like to set the metric of one of them as
higher. This would permit me to move the T20 in the house with the
wireless and when at my desk plug it in in the linksys and have
nothing to do to set it up. The problem with the 2 NICs is that if I
start both interfaces at same time, the machine will receive 2 default
routes, 2 routes to the router with the same metric. This confuse
TCP/IP and I can't communicate with my gateway to access internet.
Both NICs will are set to use DHCP to get IP address. I am not using
Network Manager since it caused me many problems before.... But this
is another issue.

With Windows this is very simple to do. You go to the property of the
NIC, property of tcp/ip, then in advanced options you may set the NIC
default metric manually to whatever you need.

I haven't been able to find out how to do this in Ubuntu yet. I have
read man pages on /etc/network/interfaces without finding any human
readable hint on how to set the metric. I have read man pages on
dhclient to try suggest DHCP to give me the metric I need without
success too. Googling has not been successfull either.

Has anybody succeeded in setting the metric of an interfaces yet ?
And if yes HOW ?

Share: 

 

8 Answers Found

 
Answer #1    Answered On: Dec 18    

This link shows how to set up NAT with 2 NICs. The T20 is not natting
anything. I just want the 2 NICs to access the same router without
having any conflict in the TCP/IP configuration. I know that it is
possible to give a priority via the metric parameter to one of the NIC
to avoid any conflict since there is two route to go out to the
same router. I haven't found out how to do it in Linux yet. My
Networking "know how" has been exceeded!

 
Answer #2    Answered On: Dec 18    

I'm replying my own post in desesperation. No luck up to now and
nobody has given me a clue on how to set up the "metric" parameter of
an interface. This is soooo easily done in windows, I'm sure it can
be done with linux too.

The man page of ifconfig says that you may set the metric, but I
haven't succeded in making it work. The command "ifconfig eth0 up
metric 10" return the following error: "SIOCSIFMETRIC: Operation not
supported". The interface does always get metric=1 as a glued and
unmovable default...

Is my question clear ? Has Anybody any clue?

 
Answer #3    Answered On: Dec 18    

Have you happened to do a Google search for that phrase?

 
Answer #4    Answered On: Dec 18    

I did google for SIOCSIFMETRIC - quite a bit of info... but my
knowledge of linux doesn't go that far.

 
Answer #5    Answered On: Dec 18    

Please see http://ubuntuforums.org.There is more geeks there than a Star Trek
convention.
You'll get a better response to answer your question.

 
Answer #6    Answered On: Dec 18    

Googling for the error message 'SIOCSIFMETRIC' I found some more
information. First : the metric parameter is not anymore valid with
ifconfig with Linux. The NIC always has the metric 1. This can be
nasty if you have more than 1 NIC. There is a package "ifmetric" that
can change all the routes associated with a specified NIC. The
interfaces and the routes must have been set up before. So if one
want to bring 2 NICs he must bring the first one and change it's
metric with ifmetric. Then, and only then, you can bring another NIC
up and repeat the process if you have more NICs. And don't forget dhcp
for the NIC if you need it too. I'm using wpa_supplicant for the
wireless nic. I have to bring up the wireless nic and then
wpa_supplicant and get an IP with dhclient.

I have a short script that does it when I need it. The first network
(eth0) is already up when I call the script :
--------------------------------------------------------
#!/bin/sh
ifmetric eth0 10
ifconfig eth2 up
iwconfig eth2 ESSID "myhomeessid" channel 1 mode managed ap
ff:ff:ff:ff:ff:ff Nickname "Broadcom BCM4318" rate 54M auto rts off
frag off key restricted s:mysecretpass txpower 19
wpa_supplicant -Dwext -ieth2 -c/etc/wpa_supplicant.conf
dhclient eth2 & sleep 2 && iwconfig eth2 ESSID "dd-wrt"
ifmetric eth2 20
exit
---------------------------------------------------------
The wpa_supplicant.conf contains the necessary info to reach my
private wireless network:
------------------------
network={
ssid="myhomeessid"
key_mgmt=WPA-PSK
psk="mysecretpass"
}
-------------------------

It's a first try and is not sophisticated at all. It allows me to
have the 2 NIC working at the same time or bring one of them I don't
need anymore down.

I hope that this stuff could help anybody with many NIC and/or a
wireless NIC. It's mostly an exercise to learn some network stuff.

 
Answer #7    Answered On: Dec 18    

On behalf of everyone, I want to thank you for posting this
solution. More often than not, people post a request for help and then
find the solution on their own but don't bother reporting their
finding to the group. You have taken an important step in helping
someone else in the future.

 
Answer #8    Answered On: Dec 18    

I get more out of this fourm than I do ubuntus. I have a question thats been in
answers for over a week. I know they are bessy but some get answereed Right
away. I dont know what they do to choose how they work them. Anyway here I get
lots fof answers ust reading te post. In case I forget thanks to all.

 
Didn't find what you were looking for? Find more on 2 NICs & howto set metric Or get search suggestion and latest updates.




Tagged: