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.
techraf
  • 4,254
  • 10
  • 29
  • 41
Miren
  • 111
  • 4
  • 1
    I think you mean "downgrade", but if you are determined to use a static address anyway see [How do I set up networking/WiFi/Static IP](http://raspberrypi.stackexchange.com/a/37921/8697) – Milliways Aug 30 '16 at 09:51

4 Answers4

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
Milliways
  • 54,718
  • 26
  • 92
  • 182
  • 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 08: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 08: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 01 '16 at 00:22
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.

Varad A G
  • 848
  • 6
  • 16
  • I still have the same problem. IP address doesnt update. – Miren Aug 30 '16 at 09: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 09: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](http://raspberrypi.stackexchange.com/a/37921/8697) 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
  • The reason it works is because you call `dhcp` in `/etc/network/interfaces`. `dhcpcd` detects this and deactivates itself, as you would see from boot messages. The original you posted, and that posted by the OP would not work. Incidentally your file is strange - it calls `wpa_supplicant`, but also includes `wpa-ssid` - not a good example for others. I suspect it is ignoring `wpa_supplicant` because you don't use `manual`. – Milliways Aug 30 '16 at 23:53
  • @Milliways It would begreat if you can please go ahead and edit the post. Then it would be easy for some one to refer it in future. – Varad A G Aug 31 '16 at 00:30
  • If you are suggesting I edit your post, I normally refrain from editing other peoples's posts (except for formatting) or to add a note indicating obsolete information. I do not know what you would want me to say. I have already posted a detailed tutorial covering Raspbian Jessie, and normally refer people to [this](http://raspberrypi.stackexchange.com/a/37921/8697). This includes information for those who want to use standard Debian networking. Earlier posts e.g. http://raspberrypi.stackexchange.com/a/26927/8697 address standard Debian networking – Milliways Aug 31 '16 at 06:06
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/44718/discussion-between-varad-a-g-and-milliways). – Varad A G Aug 31 '16 at 06:17
  • I still have the same problem....Allocate IP is the same that DHCP server gave me. root@raspberrypi:/home/pi# sudo service dhcpd status ● dhcpd.service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead) – Miren Aug 31 '16 at 06:30
  • @Miren can you please update the question with your /etc/network/interfaces , uname -a and /etc/os-release. – Varad A G Aug 31 '16 at 06:51
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

Cheetah7
  • 11
  • 1
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
screenslaver
  • 71
  • 1
  • 1
  • 7