LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Linux Ifconfig (https://www.linuxquestions.org/questions/linux-networking-3/linux-ifconfig-4175476013/)

JJJCR 09-05-2013 05:21 AM

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. :)

displace 09-05-2013 05:40 AM

Do you have only one ethernet device? Did you happen to replace the network card recently?

zhjim 09-05-2013 06:18 AM

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.

JJJCR 09-05-2013 06:55 AM

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.

druuna 09-05-2013 07:11 AM

Quote:

Originally Posted by JJJCR (Post 5022228)
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"

displace 09-05-2013 11:51 AM

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.

JJJCR 09-07-2013 05:12 AM

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?

druuna 09-07-2013 05:58 AM

Quote:

Originally Posted by JJJCR (Post 5023542)
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

JJJCR 09-07-2013 06:07 AM

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. :)

druuna 09-07-2013 06:20 AM

Quote:

Originally Posted by JJJCR (Post 5023554)
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.

JJJCR 09-07-2013 06:33 AM

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. :)

273 09-07-2013 07:47 AM

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?

JJJCR 09-07-2013 07:09 PM

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.

JJJCR 09-09-2013 08:34 PM

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 :)


All times are GMT -5. The time now is 04:09 AM.