Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a wired network connection and if I'm using network manager (hereafter "NM") everything works fine except for the hardware address (it doesn't change). I'm thinking of using /etc/network/interfaces. So, I added some code and it looks like this:

auto lo
iface lo inet loopback

auto eth1
iface eth1 inet static
address #corresponding value
netmask #corresponding value
gateway #corresponding value
hwaddress #corresponding value

After restarting networking I get the following message:

*Reconfiguring network interfaces...
#here some help code appears
Failed to bring up eth1.

The default interface that works with NM is eth0. Please advise on how to handle the problem.

share|improve this question
Assuming the interface you want to manage using the interfaces file is eth0, why is it eth1 in the file? – Oxwivi Feb 21 '11 at 19:14
I'm setting a different hw address, but at other location (it's a laptop) I'll need the "native" one. – Denys S. Feb 21 '11 at 19:17
ethernet is pretty easy to use without NM, if you want to deal with /etc/hosts and /etc/conf.d/net.eth0 directly... (assuming Ubuntu uses those, not sure) – mathepic Feb 21 '11 at 19:18
@mathepic, Neither /etc/conf.d nor /etc/conf.d/net.eth0 are there. – Denys S. Feb 21 '11 at 19:21
Aren't eth0 and eth1 hardware (not software configuration) anyway? So eth1 probably shouldn't be used for this type of thing. – mathepic Feb 21 '11 at 19:32
up vote 2 down vote accepted

eth0 or eth1 is the logical name given to your network card by Linux (I dont know exactly which component handles the naming but i guess its the kernel). you can only use eth0 or eth1 if its the logical name given to your card and not otherwise.

Coming to your original problem i.e using different hardware address at different locations, this is doable by defining logical name mapping in /etc/network/interfaces file but you will have to connect manually to network using ifup command eachtime.

To do this open your /etc/network/interfaces file and replace its contents with following

auto lo
iface lo inet loopback

mapping eth0
      script /home/<username>/
      map eth0 eth0-home
      map eth0 eth0-work

iface eth0-home inet static
      address #ip address for home
      netmask #subnet mask for home
      hwaddress ether #MAC address for home

iface eth0-work inet static
      address #ipaddress for work
      netmask #netmask for work
      hwaddress ether #MAC address for work

set the ip address, netmask and hwaddress for eth0-home and eth0-work to your liking. Also replace the <username> in fourth line of the script with your user name. Now save and close the interfaces file.

Now create a file /home/<username>/ with the following contents

echo eth0

save and close the file.

You are all set now. You can use command sudo ifup eth0=eth0-home to start network with eth0-home settings and sudo ifup eth0=eth0-work to start with eth0-work settings.

Also please note that the mapping section in interfaces file and the script file that we created in your users home directory are actually needed when the interface is configured to connect automatically. But we need to provide them for things to work. So the contents of the script file and the contents of mapping section are just sort of place holders. If you are interested in connecting automatically you will need to modify these two. For further discussion of the two you can see man page for interfaces(5) or visit the following link

share|improve this answer

You must decide if you want to use NM or the "hardcoded" config in the interfaces file. As far as I experienced it's not a good idea to mix them, you will have problems. You may want to drop using NM, ok. However names like eth0 and eth1 are assigned to ethernet NICs, so if you use eth1, I would think you have two NICs in your machine. Yes, it's possible that you have only eth1 and not eth0 (you can even rename NICs) but I don't see the point here. Please issue command /sbin/ifconfig -a in terminal and use the eth name what you can see there. If you see only eth1 and not eth0 it's ok to use too, that's possible: udev rules names interfaces according the HW address ("MAC address") to be sure, that your interfaces won't be renumbered if you change the PCI card positions and similar things. I had the experience, that replacing a card with another one caused I have only eth1 (and no eth0 at all) since udev remembers about the old card's HW address so name eth0 is reserved for that purpose, thus I had eth1 as the new NIC. I am not sure you mean about this when you want to use eth1 but it's nice to mention (btw udev stores assignment(s) here: /etc/udev/rules.d/70-persistent-net.rules).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.