1

I can't update an IP address from DHCP to static. I changed the /etc/network/interfaces file and I rebooted the system but IP still is the same as the one that DHCP gave me before.

I changed /etc/network/interfaces to:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.205
netmask 255.255.255.0
gateway 192.168.1.1

I got this error in syslog when I executed /etc/init.d/networking restart:

Aug 30 08:17:01 raspberrypi CRON[1337]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug 30 08:34:22 raspberrypi systemd[1]: Stopping LSB: Raise network interfaces....
Aug 30 08:34:22 raspberrypi rsyslogd-2007: action 'action 17' suspended, next retry is Tue Aug 30 08:34:52 2016 [try http://www.rsyslog.com/e/2007 ]
Aug 30 08:34:22 raspberrypi networking[1407]: Deconfiguring network interfaces...done.
Aug 30 08:34:22 raspberrypi systemd[1]: Starting LSB: Raise network interfaces....
Aug 30 08:34:22 raspberrypi networking[1428]: Configuring network interfaces.../etc/network/if-pre-up.d/iptables: 2: /etc/network/if-pre-up.d/iptables: /sbin/iptable-restore: not found
Aug 30 08:34:22 raspberrypi networking[1428]: run-parts: /etc/network/if-pre-up.d/iptables exited with return code 127
Aug 30 08:34:22 raspberrypi networking[1428]: ifup: pre-up script failed.
Aug 30 08:34:22 raspberrypi networking[1428]: failed.
Aug 30 08:34:22 raspberrypi systemd[1]: Started LSB: Raise network interfaces..
raspberry-pi3

uname -a gives:

Linux raspberrypi 4.4.11-v7+ #888 SMP Mon May 23 20:10:33 BST 2016 armv7l GNU/Linux

And /etc/os-release contains:

PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

I tried to execute the script /sbin/ifup, result:

root@raspberrypi:/sbin# ./ifup  -a
/etc/network/if-pre-up.d/iptables: 2: /etc/network/if-pre-up.d/iptables: /sbin/iptable-restore: not found
run-parts: /etc/network/if-pre-up.d/iptables exited with return code 127
./ifup: pre-ifup script failed.
1

If you are really determined to do it this way you need to disable the DHCP client daemon and switch to standard Debian networking:

sudo systemctl disable dhcpcd
sudo systemctl enable networking
  • root@raspberrypi:/home/pi# sudo systemctl disable dhcpcd Synchronizing state for dhcpcd.service with sysvinit using update-rc.d... Executing /usr/sbin/update-rc.d dhcpcd defaults insserv: warning: current start runlevel(s) (empty) of script dhcpcd' overrides LSB defaults (2 3 4 5). insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script dhcpcd' overrides LSB defaults (0 1 6). – Miren Aug 31 '16 at 8:54
  • insserv: script iptables.klm: service Iptables already provided! insserv: script iptables.klm: service Initial already provided! insserv: script iptables.klm: service Config already provided! – Miren Aug 31 '16 at 8:54
  • 1
    @Miren the comments are illegible. Paste any code into your question. From the look of it you are running as root. This is not normal for Raspbian, and requires system changes. Most advice will assume you are running as a normal user on an unmodified system. If you are not you need to clarify exactly what you have done. – Milliways Sep 1 '16 at 0:22
0

The best soluition that I have come across is this one. Solved my requirement for static addresses for both eth0 and wlan0 on my Rpi3

dhcpcd vs /etc/network/interfaces

good luck, ianm

0

Looks like the way we set the static ip has changed. There is a post here in the link which talks about static ip. Please look at the answer from steve(Answer 2).

Raspberry seems to ignore static ip setting

Refer the post: Connecting Raspberry Pi (running Raspbian) to open WiFi using only the command line for more details.

  • I still have the same problem. IP address doesnt update. – Miren Aug 30 '16 at 9:38
  • Have you actually tried this before giving others advice. Unless you disable dhcpcd it will still attempt to allocate addresses. – Milliways Aug 30 '16 at 9:59
  • @Milliways Yeah I have tried it on my debian system but not on my raspberry pi. I have a Ubuntu 12.04 in which I have set static ip for some testing purpose. I will be accessing my Rpi once I reach home and I don't have access now. I will give detailed steps once I set it up on my Raspberry pi. I will delete the answer if this is not allowing to set it up in my raspberry pi. Also what you mentioned is a striking point we have to disable the dhcpd service to pick up the static ip. – Varad A G Aug 30 '16 at 12:34
  • It probably works on Ubuntu (although I have not tried on 16.04 - but then I spend most of my time trying to convince people NOT to use static) and does work on Wheezy and you can configure Jessie to use the traditional Debian networking. For better or worse (I see improved performance) the Foundation uses dhcpcd by default. Ubuntu (at least current releases) uses Network Manager. Either works, but they are not the only way. See How do I set up networking/WiFi/Static IP for the Raspbian approach. – Milliways Aug 30 '16 at 12:43
  • @Milliways I tried this out in my Raspberry pi and this configuration works for me. I am pasting my "interfaces" file by editing the answer. – Varad A G Aug 30 '16 at 16:28
0

You can edit the dhcpd.conf file to set a static ip in Raspbian Jessie. This is how I changed mine.

sudo nano /etc/dhcpcd.conf

Go to the end of the file and edit the following based on your needs.

    interface eth0

    static ip_address=192.168.1.200/24
    static routers=192.168.1.1
    static domain_name_servers=192.168.1.1

    interface wlan0

    static ip_address=192.168.1.200/24
    static routers=192.168.1.1
    static domain_name_servers=192.168.1.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.