doni49
Posts: 94
Joined: Wed Jan 23, 2013 4:59 pm

Static IP not working

Sat Mar 01, 2014 4:30 am

I've been trying to get my RasPi working with static IP and it just refuses to make the connection.
Here's the output from ifconfig and netstat -nr and below that is the contents of my interfaces file (from /etc/network). The ifconfig and netstat results are both while set to dynamic IP.

NOTE: when it gets the IP address via dynamic, it gets 10.1.1.103 but I want a static IP of 10.1.1.1. That's the reason for that discrepancy -- I did however try using a static IP of 10.1.1.103. And I also deleted the IP lease from the router's memory before rebooting the RasPi with the static IP assigned.

Any ideas?
eth0 Link encap:Ethernet HWaddr b8:27:eb:86:c3:a4
inet addr:10.1.1.103 Bcast:10.1.1.255 Mask:255.255.255.0
inet6 addr: fe80::ba27:ebff:fe86:c3a4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1546 errors:0 dropped:0 overruns:0 frame:0
TX packets:627 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:127067 (124.0 KiB) TX bytes:194397 (189.8 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:212 errors:0 dropped:0 overruns:0 frame:0
TX packets:212 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:20155 (19.6 KiB) TX bytes:20155 (19.6 KiB)

Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.1.1.1 0.0.0.0 UG 0 0 0 eth0
10.1.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0

Code: Select all

auto lo

iface lo inet loopback
iface eth0 inet static
address 10.1.1.3
netmask 255.255.255.0
network 10.1.1.0
broadcast 10.1.1.255
gateway 10.1.1.1


User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Static IP not working

Sat Mar 01, 2014 5:09 am

Here is what works for me.

Code: Select all

    auto lo

    iface lo inet loopback
    iface eth0 inet static
    address 10.232.1.81
    netmask 255.255.255.0
    gateway 10.232.1.1


 
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
blachanc
Posts: 466
Joined: Sat Jan 26, 2013 5:03 am
Location: Quebec,canada(french)

Re: Static IP not working

Sat Mar 01, 2014 5:22 am

Richard-TX wrote:Here is what works for me.

Code: Select all

    auto lo

    iface lo inet loopback
    iface eth0 inet static
    address 10.232.1.81
    netmask 255.255.255.0
    gateway 10.232.1.1

sorry for a bit of highjacking the thread, but I always wondered what is the benefit from setting the IP via the PI vs reserving the IP via the router? I am sure there is a good reason, but fail to capture it.

Ben
Autism/Asperger syndrome: what is your score on this quiz?
http://www.raspberrypi.org/forums/viewtopic.php?f=62&t=70191

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Static IP not working

Sat Mar 01, 2014 5:26 am

Ther reason for a fixed IP address is so that the IP address is always known. With DHCP, it is like a box of chocolates.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

doni49
Posts: 94
Joined: Wed Jan 23, 2013 4:59 pm

Re: Static IP not working

Sat Mar 01, 2014 5:35 am

I think he was asking about doing it directly on the device as opposed to reserving the IP at the router. In my case, my router doesn't do that -- my only options are leave it as dynamic IP or set up the device to do static IP.

I've got another RasPi on the same network and it's working on static IP fine.

User avatar
blachanc
Posts: 466
Joined: Sat Jan 26, 2013 5:03 am
Location: Quebec,canada(french)

Re: Static IP not working

Sat Mar 01, 2014 5:44 am

doni49 wrote:I think he was asking about doing it directly on the device as opposed to reserving the IP at the router. In my case, my router doesn't do that -- my only options are leave it as dynamic IP or set up the device to do static IP.

I've got another RasPi on the same network and it's working on static IP fine.
Yes, you are right this is what I was wondering. I missed the obvious ;)
Based on your explanation, I will make sure my next router still allows DHCP reservations :D

thanks to both of you for the explanations.

Ben
Autism/Asperger syndrome: what is your score on this quiz?
http://www.raspberrypi.org/forums/viewtopic.php?f=62&t=70191

doni49
Posts: 94
Joined: Wed Jan 23, 2013 4:59 pm

Re: Static IP not working

Sat Mar 01, 2014 5:47 am

I just copied this from the RasPi that IS working. I had previously copied this over to the other one (and changed the address from 10.1.1.2 to 10.1.1.3) and it refused to work. I know there's not anything else on the network using this address. I just set this router up tonight (just bought it used and did a factory reset myself then changed the ip address).

With the exception of these two RasPi Devices, everything on my network uses dynamic IP (the router is configured so that all dynamic addresses are in the range 10.1.1.100 to 10.1.1.50 and I've confirmed that all the other devices on my network are in this range).

In addtion, just to be sure, I did try using the following addresses:
10.1.1.11
10.1.1.15
10.1.1.103 (this is the IP that was assigned to it under dynamic)

I've also since tried copy pasting your code into my file (of course changing the address/gateways to for my network).

No joy anywhere. :?

Code: Select all

auto lo

iface lo inet loopback
iface eth0 inet static
      address 10.1.1.2
      netmask 255.255.255.0
      gateway 10.1.1.1

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

doni49
Posts: 94
Joined: Wed Jan 23, 2013 4:59 pm

Re: Static IP not working

Sat Mar 01, 2014 5:52 am

Also: the code that I originally posted is a little different from what you posted as well as from what is working on the other RasPi. When I started experiencing this problem, I started searching for answers. I came across this posting which is where I got this info:

https://www.modmypi.com/blog/tutorial-h ... ip-address

User avatar
rpdom
Posts: 17174
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Static IP not working

Sat Mar 01, 2014 7:04 am

I can't see an "auto eth0" or "allow-hotplug eth0" line in that interfaces file.

doni49
Posts: 94
Joined: Wed Jan 23, 2013 4:59 pm

Re: Static IP not working

Sat Mar 01, 2014 7:11 am

Does it matter which one I use? What's the difference between them?

I don't know where I got what I have now. But since it works, I tried copying it over to the new one.

doni49
Posts: 94
Joined: Wed Jan 23, 2013 4:59 pm

Re: Static IP not working

Sat Mar 01, 2014 7:29 am

Ok. I found something that helped. Based on that, I put the hotplug line in and rebooted it. It's working now. Thanks for the help! I appreciate it!

http://www.debian.org/doc/manuals/debia ... nterfaces

"auto <interface_name>" start interface <interface_name> upon start of the system
"allow-hotplug <interface_name>" start interface <interface_name> when the kernel detects a hotplug event from the interface

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: Static IP not working

Sat Mar 01, 2014 7:34 am

Strange because looking at the result of the ifconfig you posted, your interface was UP and the RX/TX packets counter were showing something.

Glad your fixed that.
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

doni49
Posts: 94
Joined: Wed Jan 23, 2013 4:59 pm

Re: Static IP not working

Sat Mar 01, 2014 7:38 am

The IFConfig that I posted was from being run as dynamic. I provided that info so that anyone trying to assist would be able to see the network settings that I needed to get the RasPi to use in static mode.

Return to “Networking and servers”