Fixed IP address problems

I've had the Pi working for some time using DHCP on a wired connection to my modem/router and connected to a wired dual boot Windows 8/Linux Mint desktop. Putty and Ultra VNC both work and I can ping both the IP address and the name raspberrypi on both OSs.

So, not being content with this happy state of affairs, I decided to fix the Pi's IP address.

I changed the line in /etc/networks/interfaces

from: iface eth0 inet dhcp

to: iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.254

and rebooted the Pi and the Win8 machine. I can ping 192.168.1.100 but not raspberrypi. I noticed that the router had changed raspberrypi to

192.168.1.100 but it hadn't changed from DHCP to static so I switched it off and on again. It now shows static.

Having once again rebooted the Pi and Win8 machine I still can't ping raspberrypi. The Pi can access the internet (I can still control it via Putty).

I can (and have) gone back to DHCP so everything works, but I'd like to fix the little bastard's IP address. I feel that I'm missing something simple.

Any suggestions?

Another Dave

Reply to
Another Dave
Loading thread data ...

I always used to allocate manual addresses on my LAN, but these days if I want to fix an address I usually do it on the DHCP server by associating it with the device's MAC address.

Reply to
Rob Morley

Try flushing the DNS cache. Never used Win-8, in previous versions of Windows the command is "ipconfig /flushdns"

--
Roberto Waltman 

[ Please reply to the group, 
  return address is invalid ]
Reply to
Roberto Waltman

Thanks for the reply. I tried the command, it seemed to be acceptable to Win8 but it didn't fix the problem (even after a re-boot) and it wouldn't explain the failure in Linux anyway.

Another Dave

Reply to
Another Dave

I'm not sure I understand you. I assume the DHCP server is the modem/router but I can't find the facility you refer to in its menus. By "address" do you mean the Pi's IP address (192.168.1.100) or its name "raspberrypi"? Is the "MAC address" what my router refers to as the Physical Address?

Sorry to be a bit slow.

Another Dave

Reply to
Another Dave

Then you have a DNS/host table issue.

yu need to run your own DNS or edit your hosts file

--
Ineptocracy 

(in-ep-toc?-ra-cy) ? a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Reply to
The Natural Philosopher

This manifests itself that with a static ip address you cannot use the dns name any longer, but an IP address works fine. Like with ssh, ping etc?

In which case you have some kind of DHCP to DNS bridge like dnsmasq or similar. This bridge picks up the name the DHCP client presents to the server ("raspberrypi" is the default for our favourite OS) and the server enters it into it's DNS table for the duration of the DHCP lease; pointing to the correct IP address.

With static IP addresses there are no longer such an exchange, and you must enter the DNS name manually into wherever you configure your DNS. This may include MAKING a DNS server.

These names typically require a dot, like "raspberrypi.myname.com" or "raspberrypi.local". See a DNS manual for the details.

Or just leave it to dnsmasq.

-- mrr

Reply to
Morten Reistad

Your router is probably advertising itself as a DNS resolver and it maintains a local zone derived from DHCP information. Once you stop using DHCP your router no longer does that for you, and it remains working for a short while because of caches and DHCP lease period. After that, it fails.

You will need to tell your router about the static mapping from raspberrypi to 192.168.1.100 or put that mapping in the hosts files of the other computers.

Reply to
Rob

One possible solution. In Windows, system32\drivers\etc, edit the file hosts. with Notepad to add the line:

192.168.1.100 raspberrypi

With my pack of RPi cards I have:

192.168.0.51 raspi-1 192.168.0.52 raspi-2 192.168.0.53 raspi-3

and so forth. I also like Rob's suggestion of reserving IP addresses against MAC addresses in your router.

I found my initial information here:

formatting link

There is also a hosts file in Linux.

--
Cheers, 
David 
Web: http://www.satsignal.eu
Reply to
David Taylor

Of course! (Banging my forehead.) You need a replacement for the DNS server (1) or, much easier, add this line to the hosts file in all your systems:

192.168.1.100 raspberrypi

R. (1) Search for "dual DHCP DNS server" for a good windows setup

--
Roberto Waltman 

[ Please reply to the group, 
  return address is invalid ]
Reply to
Roberto Waltman

Possibly the shortest way is to ID the MAC of the PI and tell the router to assign it a fixed IP address based on its MAC address.

Then it still gets its IP via DHCP and all works, but its on a fixed address too.

--
Ineptocracy 

(in-ep-toc?-ra-cy) ? a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Reply to
The Natural Philosopher

Bingo!

Many thanks to all who came up with this and other suggestions. I've spent quite a while searching for a solution so it's quite a relief. Usenet is the best!

None of the guides to fixing the IP address even mention this requirement so I'm surprised they got it to work.

Another Dave

Reply to
Another Dave

It is not a requirement, just a convenience. Most people setting fixed IP probably access the device via that IP.

And also, the support from your router to put DHCP-assigned addresses into its local DNS resolver is just a luxury, not all routers do that.

Reply to
Rob

After my last post I discovered that Windows 8 Defender (which I use) will replace any modified Hosts file by its default unless you specifically exclude the Hosts file from it. This would have caused me a lot of confusion if I hadn't found this out.

The URL you gave me is an example of what I was talking about - there's no mention of the Hosts file. Indeed, I think I used this page myself.

Another Dave

Reply to
Another Dave

It's not a convenience or a luxury. If Ultravnc hadn't put "raspberrypi:1" up in its address box, I'd have been quite happy typing in 190.168.1.100 till kingdom come and I would have saved myself a lot of time :-(

Another Dave

Reply to
Another Dave

If the Pi can access the internet, there is nothing wrong on the Pi! The problem is the other systems either don't know about the Pi or are being blocked by a router or other device. Possibly the subnet they are on is smaller than 255.255.255.0

Jon

Reply to
Jon Elson

Yes, it's a (supposedly) unique hardware identifier written in the firmware of every network device by the manufacturer - MAC stands for Media Access Control. When a device makes a DHCP request the packet includes its MAC address, the router checks if that MAC is in its table of reserved IPs/MACs, and if it is then it sends that IP address back to the client, along with the other DHCP information.

Reply to
Rob Morley

On 09/07/2013 20:04, Another Dave wrote: []

Dave,

I'm glad that resolved the problem.

I did just check on one of my own Windows-8 PCs which runs Windows Defender, and it didn't appear to have replaced the hosts file with the default. To edit the file, I had got a command prompt with "Run as Administrator", and then used:

Notepad C:\Windows\system32\Drivers\etc\hosts

Perhaps if the file security is changed to allow user editing, that's what Windows Defender detects and doesn't like?

--
Cheers, 
David 
Web: http://www.satsignal.eu
Reply to
David Taylor

Another thing. If you do use any genuine static IP addresses make sure they're *not* in the router's DHCP range.

--
(\__/)  M. 
(='.'=) If a man stands in a forest and no woman is around 
(")_(") is he still wrong?
Reply to
Mark

Or preferably, that they are issued BY the router based on the pi's MAC address. .

--
Ineptocracy 

(in-ep-toc?-ra-cy) ? a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Reply to
The Natural Philosopher

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.