LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   static IP (or name server?) (https://www.linuxquestions.org/questions/linux-networking-3/static-ip-or-name-server-858914/)

adrianmariano 01-26-2011 08:23 PM

static IP (or name server?)
 
I have two linux machines plugged into my wired router and I had set them to have static IPs so that I could ssh between them. I then listed their static IPs in each machine's /etc/hosts.

This all worked fine. But I just upgraded hardware and it doesn't work any more.

So my /etc/network/interfaces looks like this:

Code:

auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
#iface eth0 inet dhcp
iface eth0 inet static
      address 192.168.1.99
      netmask 255.255.255.0
      gateway 192.168.1.1
      dns-nameservers 68.100.16.25 68.100.16.30  68.105.28.12
      dns-search cox.net

And ifconfig gives me this:

Code:

root# ifconfig
eth1      Link encap:Ethernet  HWaddr 70:71:bc:dd:29:17 
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::7271:bcff:fedd:2917/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2056404 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1838660 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2026298633 (1.8 GiB)  TX bytes:526334810 (501.9 MiB)
          Interrupt:20 Memory:f7200000-f7220000

When I tried changing the stuff in the interfaces file to refer to eth1 I believe the networking device came up as eth2, but I can't double check that without rebooting. Mysteriously when I type "ifdown eth1" I get the error "ifdown: itnerface eth1 not configured." And if I do "/etc/init.d/networking stop" the networking doesn't actually stop. Is something else handling the networking? I'm in kernel 2.6.37-trunk-686-bigmem on one machine (because it's sandybridge) and the latest testing, 2.6.32 on the other one

So I'm a little confused about this. The only reason I care about static IPs is that I want to be able to ssh or scp files between machines. It would be nice if I could do the same with a mac that is connecting to the LAN wirelessly as well.

So is there some way to fix things so I again get static IPs? Or should I run a name server somehow or do something else to solve this problem? (That seems like a more complex solution.)

frankbell 01-26-2011 08:27 PM

Which hardware did you upgrade?

If it was the router, check the DHCP settings in the router and make sure they are not conflicting with your static ip settings in your computer.

adrianmariano 01-26-2011 08:44 PM

Old motherboard died so I got a new motherboard, cpu and RAM. All other hardware, including the router, is the same.

I double checked the DHCP settings in the router. I have starting IP set to 192.168.1.100, which shouldn't conflict. From the ifconfig output it is apparent that it got the first DHCP IP number.

frankbell 01-26-2011 09:57 PM

Cool.

Try setting the computers back to DHCP and testing, running ifconfig and checking the settings, then resetting to the static ip.

What I find a little puzzling is that, in my Linux computers, regardless of the distro, the wired ethernet is invariably eth0, not eth1.

adrianmariano 01-26-2011 10:34 PM

It sure would be easier to test stuff if I could figure out a way to reset the networking that didn't require rebooting. Why does "ifdown eth1" tell me I have no such device when ifconfig lists eth1 as the device?

I got the impression somehow that the system went to eth1 because it didn't like the config info I put in for eth0. I was surprised to see it list eth1. Also note that the config does specify eth0. Could some other network configuration application be at work? I think I saw something in a man page about some dhcp stuff having its own config and not paying attention to /etc/network/interfaces.

Dani1973 01-27-2011 06:42 AM

have you tried changing "allow-hotplug eth0" to "auto eth0" ?

adrianmariano 01-27-2011 05:07 PM

So I tried "auto eth0" and the behavior was unchanged. Running ifconfig still showed eth1 as the device, and with the wrong IP.

I went through and changed all the references from eth0 to eth1. I swear I did this before...but this time it worked. I also find that ifdown and ifup work now to take down and bring up eth1. (But whatever happened the eth0??)

And if that isn't strange enough, I went over to my other machine and ran ifconfig and found that it was listing eth2 as the device. I went through the interfaces file and changed the references to all indicate eth2. And that worked too.

So I feel like I don't really understand what's going on...but the problem seems to be solved.

Noway2 01-28-2011 04:22 AM

I suspect that when you changed the motherboard, the adapter MAC address changed and at least part of what is happening is that you have left over information mapping your old adapter to eth0. Consequently, your new adapter is being declared eth1, but since there is no eth0 things are getting messed up.

I believe that the device mapping information is normally handled by udev. For example, on my system (Ubuntu / debian) the file /etc/udev/rules.d/70-persistent-net.rules contains the mapping and ordering of the MAC address to eth devices. While this will vary according to distribution, you probably have something very similar and if you remove the old MAC address, your eth device will probably revert back to eth0.

Here is a link to some info on udev (it is for debian, but seems to contain a lot of generic information too.

jlinkels 01-28-2011 04:51 AM

The file might be called differently, but should have something like persistent-net as part of the file name. Delete any line which ends in eth0 or eth1, and reboot. You'll have eth0 back and this will be assigned the correct IP.

jlinkels

adrianmariano 01-28-2011 05:03 PM

I located that udev file and sure enough, there were entries left over from old networking devices. I deleted the obsolete entries, and tweaked the remaining entry to specify eth0 and now the device comes up as eth0. (And with the interfaces file modified to specify eth0, I get the desired static ip.) So now everything is worked as expected and desired.

Thanks.


All times are GMT -5. The time now is 10:38 PM.