I would like a static IP address on my Pi running Raspbian. I can get this if I use an ethernet cable, but my connection is via WLAN. I have been unable to get a static address using WLAN. Should I be modifying a different file to achieve this rather than /etc/network/interfaces.
All my googling and reading only covers ETH0. Any help appreciated
Malcolm Smith
--
T M Smith
Using an Iyonix and RISC OS 5.20 in the North Riding of Yorkshire
Another way (probably better if you have DHCP-allocated addresses on the network) is to still use DHCP on the pi, but configure the DHCP server to always allocate 192.168.178.14 to your wifi ethernet address. That way, your IP addresses are all still managed from one place, the DHCP server. Also, if you do ever need to connect your pi into another network, it will still get a valid address on that network, and work properly.
--
Andrew Gabriel
[email address is not usable -- followup in the newsgroup]
Agreed. However, my DHCP server does not always reliably serve the same address to a given machine, so I have set static addresses on those clients I never use outside my home net. The DHCP server is configured to provide addresses 20 and up to all the other clients.
What DHCP server? Nearly all the DHCP servers I've come across have a specific option to make them always allocate the same IP address to a particular MAC address. It usually happens that A DHCP server allocates the same IP to the same MAC but it's not *forced* to unless you configure it that way.
That depends a lot on the server. "server" DHCP is often different from "consumer NAT router". Some DHCP servers in routers have a memory across reboots, others have not. Some clients remember leases and re-request the same address when they reboot, others do not. All in all it really is not reliable unless there is some explicit MAC->IP mapping in the server.
I have not come across a consumer DHCP server (in a router, etc) which doesn't have an explicit MAC->IP mapping table, which is stored in non-volatile memory.
--
Andrew Gabriel
[email address is not usable -- followup in the newsgroup]
I've not come across one (and I have quite a few - several TP-Link ones, a Tenda one, a Zyxel one, a Draytek one and a couple of BT labelled ones) that doesn't allow one to specify that a particular MAC address should always be given the same IP address. They *all* have some sort of flash memory that is remembered across reboots and power cycles, otherwise they'd always need complete reconfiguration after a power cycle.
You do need to *explicitly* set the configuration to make the IP address stay the same though, they don't normally default to that.
But that is different from "server" DHCP. ISC DHCP remembers the MAC to IP mapping by default. You don't need to configure anything for that, nor do you have to setup the mapping yourself. There are routers that do that as well.
Get an ASUS router, the firmware on them is pretty good, and I've had no problems setting up static addresses for everything (including several Raspberry Pi's), which have survived power cycles.
I've got a RT-ac68U and upgraded all our laptops with an Intel 7260 AC cards. Most have gigabit ethernet, but on the one which only has 100Mbit ethernet the Wireless is now faster, doing over 250Mb/s on 5GHz. It's a pitty you can't bypass the Pi's slow 100Mb networking, as a wireless-AC adaptor would also be limited by the USB bus, as is the ethernet.
I think there is something "odd" about how Raspberry's request a lease. The DHCP server here gives everyhing the same address as it had before, even over long periods of abscence but the two Raspberry's can get different address's by a simple reboot. It might be related to booting between different OS's but the MAC doesn't change...
Just had my Kodi (XBMC) Raspberry move IP address. We had a short power cut in the we small hours so it had the power yanked. "Short" was longer than 2 mins as the server/router/firewall had shut down. On powering it back up (its the DHCP server) the Kodi Pi got a different IP address. The Pi running a stills/timelapse webcam, that also had it's power yanked, got the same address as it had before.
The DHCP/bootp/etc protocols are designed to give a very high stability in the assignments of IP addresses. Both the host and the server has as much persistent memory as hardware permits.
A client will ask for the same IP address as it had the last time, and the server should assign that, pending some arp-ing on the net to see that this address is indeed unused. The server should also keep client addresses in backing store to be reassigned when they come back.
A correctly implemented dhcp client and server will hardly ever change the IP addresses. The only instance this happens is when there is a general scarcity of IP addresses, or if a host is offline for a long time (weeks).
I have had dhcp running on a ddwrt router for 4 years now, and all the boxes keep the same IP address they had for years.
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.