LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-05-2013, 05:21 AM   #1
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,288

Rep: Reputation: 467Reputation: 467Reputation: 467Reputation: 467Reputation: 467
Cool Linux Ifconfig


hi guys when i type the command, cat /etc/network/interfaces it will show this result:

Quote:
root@xxgo:/home/cxs# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The primary network interface
auto eth1
iface eth1 inet static
address 192.168.1.13
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254

auto eth0
iface eth0 inet static
address 192.168.1.12
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
but when i type ifconfig -a it has a different result:

Quote:
root@xxgo:/home/cxs# ifconfig -a
eth2 inet addr:192.168.1.146 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1544 errors:0 dropped:0 overruns:0 frame:0
TX packets:243 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:143669 (140.3 KiB) TX bytes:30573 (29.8 KiB)
Interrupt:23 Base address:0x2000
any ideas guys, why the eth0 and eth1 does not appear on ifconfig -a?

why the eth2 comes into play when there is already a static IP defined?

thank you for any input.
 
Old 09-05-2013, 05:40 AM   #2
displace
Member
 
Registered: Jan 2013
Location: EU
Distribution: Debian
Posts: 269

Rep: Reputation: 25
Do you have only one ethernet device? Did you happen to replace the network card recently?
 
Old 09-05-2013, 06:18 AM   #3
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Please provide the output of /etc/udev/rules.d/70-persistent-net.rules.

Just a hint. Maybe try the ip binary. It like it far better than ifconfig.

ip link - shows all interfaces
ip addr - shows ip addres of all interfaces
ip route - shows active rules
man ip - well the man page.
 
Old 09-05-2013, 06:55 AM   #4
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,288

Original Poster
Rep: Reputation: 467Reputation: 467Reputation: 467Reputation: 467Reputation: 467
only one interface on the pc.

I recently clone a server and restore the image on a pc.

I don't know whether turning off the DHCP on linux will help. I'm using Ubuntu.
 
Old 09-05-2013, 07:11 AM   #5
anon237
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by JJJCR View Post
only one interface on the pc.

I recently clone a server and restore the image on a pc.
Cloning a machine will cause this (very common in Virtual Machines).

Udev is the reason this will happen, provide the output of:
- cat /etc/udev/rules.d/70-persistent-net.rules
- ip link list
- dmesg | grep "eth[0-9]: addr"
 
Old 09-05-2013, 11:51 AM   #6
displace
Member
 
Registered: Jan 2013
Location: EU
Distribution: Debian
Posts: 269

Rep: Reputation: 25
Let me try to explain. UDEV is a program on your linux that tries to keep the name of your network interfaces consistent. It does this by reading the NIC's mac address and creates a rule inside /etc/udev/rules.d/70-persistent-net.rules file. So next time a computer boots it will read this file and set the interface names accordingly. Each time a new network device is detected, a new name will be generated for it. Since you cloned the OS, the udev detected that a new hardware is present, thus giving the NIC a new name - eth2. The interfaces eth0 and eth1 are locked to their mac addresses. Of course these interfaces will not be present ever again, but udev doesn't know that.

So the solution for you is to edit out the /etc/udev/rules.d/70-persistent-net.rules file, and remove any references to eth0 and eth1. Finally rename the 3rd entry from eth2 to eth0 and reboot.
 
1 members found this post helpful.
Old 09-07-2013, 05:12 AM   #7
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,288

Original Poster
Rep: Reputation: 467Reputation: 467Reputation: 467Reputation: 467Reputation: 467
there is no /etc/udev/rules.d/70-persistent-net.rules

i can't find it

any ideas guys? where to find eth2 and put back eth0 interface?
 
Old 09-07-2013, 05:58 AM   #8
anon237
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by JJJCR View Post
there is no /etc/udev/rules.d/70-persistent-net.rules

i can't find it
Strange, Ubuntu does use this method and should recreate the rule when it is missing:
- Fix Missing eth0 When Cloning Ubuntu VMware Virtual Machines

Maybe this link might help to recover it:
- How to regenerate the /etc/udev/rules.d/70-persistent-net.rules file on Debian/Ubuntu
 
Old 09-07-2013, 06:07 AM   #9
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,288

Original Poster
Rep: Reputation: 467Reputation: 467Reputation: 467Reputation: 467Reputation: 467
hi druuna, this not a latest version of Ubuntu.

It's Feisty Ubuntu 7.04, actually, i created manually the 70-persistent-net.rules but no joy.

The original server, I had checked also it doesn't have this 70-persistent-net.rules.

Where does Linux keeps it new find hardware devices? is there some sort of a conf file that it keeps its data for newly find devices such as NIC?

Thanks for any input.
 
Old 09-07-2013, 06:20 AM   #10
anon237
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by JJJCR View Post
hi druuna, this not a latest version of Ubuntu.

It's Feisty Ubuntu 7.04
It might have been a good idea to mention that you are using a 6 year old, unsupported distro.......

Underlying problem is still the same though: Hardware address of the network interface was changed due to cloning.

I don't have a clue how (very) old Ubuntu version might have handled this.
 
Old 09-07-2013, 06:33 AM   #11
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,288

Original Poster
Rep: Reputation: 467Reputation: 467Reputation: 467Reputation: 467Reputation: 467
thanks for the reply, new version is handled by 70-persistent-net.rules.

But for sure, 6 year old distro has a way of handling it. But might just be in a different way.

One thing I have in mind, is to rename the info on /etc/network/interfaces because the info on /etc/network/interfaces is still the old info from the clone server.

while i'm typing this, something cross my mind. The MAC on /etc/network/interfaces is still the old MAC of the server.

But I had shutdown the machine so I can't connect remotely but hope this idea will work.

If you have any ideas on mind guys, please spit it out and help me.

Thanks for any ideas.

I will update this post if changing the MAC on /etc/network/interfaces will help.
 
Old 09-07-2013, 07:47 AM   #12
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
If it's a VM couldn't you change the MAC of the virtual network card to match what it was on the old instance, or am I missing something?
 
Old 09-07-2013, 07:09 PM   #13
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,288

Original Poster
Rep: Reputation: 467Reputation: 467Reputation: 467Reputation: 467Reputation: 467
hi 273, i restored it to a PC.

what i mean by changing the MAC, i'm not changing the MAC physically on the NIC itself. But what I mean is is change the text file on /etc/network/interfaces.

I don't know whether this will work, or how does the old distro or Linux remember different NIC?

Because everyone is talking about 70-persistent-net.rules, which the old distro don't have.

There should be some sort of a database file (if that's the right term) on Linux, when the NIC is change or any hardware.

System is smart to remember different hardware and will use different name.

Like the NIC for example since it's a different NIC and eth0, eth1 was used by the old machine, and on the machine in which I restored the distro Linux change to eth2 since it's a different hardware and eth0 and eth1 was used before already.

And I presume if I will load back this image to the original machine, the NIC will automatically change to eth0 since the distro is able to detect the original hardware.

Last edited by JJJCR; 09-07-2013 at 10:32 PM. Reason: edit
 
Old 09-09-2013, 08:34 PM   #14
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,288

Original Poster
Rep: Reputation: 467Reputation: 467Reputation: 467Reputation: 467Reputation: 467
Quote:
root@xxgo:/home/cxs# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The primary network interface
auto eth1
iface eth1 inet static
address 192.168.1.13
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254

auto eth0
iface eth0 inet static
address 192.168.1.12
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
it wasn't that complicated after all, in /etc/network/interfaces I just change eth1 to eth3 and eth0 to eth2 and it works.

Thanks for all the help guys
 
  


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
connecting /sbin/ifconfig to bash command ifconfig flammable2 Fedora 4 11-12-2005 07:58 AM
How do I add another IP to my linux box using ifconfig via ssh? abefroman Linux - Software 3 11-11-2005 06:34 PM
Ifconfig Linux vs. FreeBSD rabbit7 Linux - Newbie 4 10-19-2004 02:18 AM
ifconfig & dhcp on linux saajii Linux - Networking 3 10-05-2004 01:24 PM

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

All times are GMT -5. The time now is 01:26 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