I've been trying for a few days now to set a static IP for my Pi but have so far been unsuccessful.
I have a Model B Revision 2.0 (revision code 000d). I'm running Jessie Lite released 2016-05-27.
Previously I used to set an IP in /etc/network/interfaces but I have now read from multiple sources that the correct way is to edit /etc/dhcpcd.conf. Some sources suggest only to edit dhcpcd.conf, some suggest editing both. I have tried both.
Currently I have the following...
# Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.1.10 gateway 192.168.1.1 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255
interface eth0 static ip_address=192.168.1.10/24 static routers=192.168.1.1 static domain_name_servers=192.168.1.1 # A sample configuration for dhcpcd. # See dhcpcd.conf(5) for details. # Allow users of this group to interact with dhcpcd via the control socket. #controlgroup wheel # Inform the DHCP server of our hostname for DDNS. hostname # Use the hardware address of the interface for the Client ID. clientid # or # Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361. #duid # Persist interface configuration when dhcpcd exits. persistent # Rapid commit support. # Safe to enable by default because it requires the equivalent option set # on the server to actually work. option rapid_commit # A list of options to request from the DHCP server. option domain_name_servers, domain_name, domain_search, host_name option classless_static_routes # Most distributions have NTP support. option ntp_servers # Respect the network MTU. # Some interface drivers reset when changing the MTU so disabled by default. #option interface_mtu # A ServerID is required by RFC2131. require dhcp_server_identifier # Generate Stable Private IPv6 Addresses instead of hardware based ones slaac private # A hook script is provided to lookup the hostname if not set by the DHCP # server, but it should not be run by default. nohook lookup-hostname
With the above set, the Pi ends up with two IP addresses. Ouput of "ip addr":
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether b8:27:eb:fd:ea:5e brd ff:ff:ff:ff:ff:ff inet 192.168.1.10/24 brd 192.168.1.255 scope global eth0 valid_lft forever preferred_lft forever inet 192.168.1.127/24 brd 192.168.1.255 scope global secondary eth0 valid_lft forever preferred_lft forever inet6 fe80::ba27:ebff:fefd:ea5e/64 scope link valid_lft forever preferred_lft forever
I've also tried stopping DHCP with the following: sudo update-rc.d -f dhcpcd remove
But after a reboot it still ends up with two IPs.
Edit: Forgot to mention, this is a wired connection. No wireless.
Edit: I know that I shouldn't have to edit both files. The above configuration is the last in a long series of combinations tried for the sake of trying everything.
If I edit only the interfaces file, it get two IPs. If I edit only the dhcpcd.conf file, It gets one IP assigned by dhcp (not the static one I've set).
sudo update-rc.d -f dhcpcd remove does not stop dhcp after a reboot.
sudo systemctl stop dhcpcd.service crashes the Pi and has no effect after pulling the power and plugging in again.
How can I stop DHCP?