LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Static IP not taking (https://www.linuxquestions.org/questions/linux-newbie-8/static-ip-not-taking-4175561677/)

NotionCommotion 12-17-2015 08:47 AM

Static IP not taking
 
I have a Raspberry pi connected to my LAN via wifi, and the hardwired Ethernet is not connected. As for as I could tell, my static IP is 192.168.1.199. Agree?

Code:

pi@raspberrypi ~ $ ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:77:55:11
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:72 errors:0 dropped:0 overruns:0 frame:0
          TX packets:72 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:6288 (6.1 KiB)  TX bytes:6288 (6.1 KiB)

wlan0    Link encap:Ethernet  HWaddr 00:0f:60:06:f5:43
          inet addr:192.168.1.199  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2666 errors:0 dropped:1166 overruns:0 frame:0
          TX packets:428 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:445192 (434.7 KiB)  TX bytes:69767 (68.1 KiB)

pi@raspberrypi ~ $ cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
#iface wlan0 inet manual
#Above line deleted and next 5 lines added by Michael
iface wlan0 inet static
address 192.168.1.199
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

pi@raspberrypi ~ $ cat /etc/resolv.conf
# Generated by resolvconf
nameserver 192.168.1.1
pi@raspberrypi ~ $ cat /etc/hosts
127.0.0.1      localhost
::1            localhost ip6-localhost ip6-loopback
fe00::0        ip6-localnet
ff00::0        ip6-mcastprefix
ff02::1        ip6-allnodes
ff02::2        ip6-allrouters

127.0.1.1      raspberrypi
pi@raspberrypi ~ $

And I could ping it from another machine which is good. But then I found this crazy other ip 192.168.1.173 on my network. I see who it is using "host", and I find it is the Pi. Furthermore, 192.168.1.199 doesn't have a host name.

Please explain what is happening. Thank you

Code:

[root@devserver ~]# ping 192.168.1.199
PING 192.168.1.199 (192.168.1.199) 56(84) bytes of data.
64 bytes from 192.168.1.199: icmp_seq=1 ttl=64 time=1.81 ms
64 bytes from 192.168.1.199: icmp_seq=2 ttl=64 time=1.27 ms
64 bytes from 192.168.1.199: icmp_seq=3 ttl=64 time=1.71 ms
^C
--- 192.168.1.199 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2558ms
rtt min/avg/max/mdev = 1.274/1.603/1.819/0.236 ms
[root@devserver ~]# ping 192.168.1.173
PING 192.168.1.173 (192.168.1.173) 56(84) bytes of data.
64 bytes from 192.168.1.173: icmp_seq=1 ttl=64 time=1.55 ms
64 bytes from 192.168.1.173: icmp_seq=2 ttl=64 time=3.99 ms
64 bytes from 192.168.1.173: icmp_seq=3 ttl=64 time=1.28 ms
^C
--- 192.168.1.173 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2935ms
rtt min/avg/max/mdev = 1.281/2.277/3.993/1.219 ms
[root@devserver ~]# host 192.168.1.173
173.1.168.192.in-addr.arpa domain name pointer raspberrypi.
[root@devserver ~]# host 192.168.1.199
Host 199.1.168.192.in-addr.arpa. not found: 3(NXDOMAIN)
[root@devserver ~]#


swampthing001 12-17-2015 09:03 AM

Could it be the IP address from when you plugged in the ethernet? Assuming you used the ethernet port if it was set to dhcp at somepoint.

NotionCommotion 12-17-2015 09:08 AM

Hi Swampthing. I don't think so. I am sure it originally had the hardwired Ethernet setup with dhcp, but currently, it is not even plugged in.

swampthing001 12-17-2015 09:32 AM

well you can ping it. is it the machine you pinged the pi from?

erik2282 12-17-2015 09:32 AM

What machine provides your DNS, your wireless router? check in its DHCP tables for these IP's and hostnames, may need to clear or correct entries.

berndbausch 12-17-2015 10:10 AM

ifconfig has its limits after a long life of about 30 years. Perhaps it doesn't show everything.

Run ip address for ip addresses and ip route for the routing table. Also check the arp cache right after running the ping test (ip neighbor) to see the MAC address of 192.168.1.173.
If you don't like typing, you can abbreviate the commands: ip a, ip r, ip n.

The fact that 199 doesn't have a host name is unrelated. You need to configure the host name on the DNS server.

NotionCommotion 12-17-2015 10:39 AM

Okay, I see 192.168.1.173 when using ip address and ip route, but don't know what it means. "secondary wlan0"?

Also, how should I check the arp cache?. See the bottom for when I used arp -a. Also, I see man arp says it is obsolete and I should use ip neighbor.

Thanks

Quote:

Originally Posted by berndbausch (Post 5465524)
Run ip address for ip addresses and ip route for the routing table. Also check the arp cache right after running the ping test (ip neighbor) to see the MAC address of 192.168.1.173.

Code:

pi@raspberrypi ~/bacnet-stack-0-8-0 $ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    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
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether b8:27:eb:77:55:11 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:0f:60:06:f5:43 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.199/24 brd 192.168.1.255 scope global wlan0
      valid_lft forever preferred_lft forever
    inet 192.168.1.173/24 brd 192.168.1.255 scope global secondary wlan0
      valid_lft forever preferred_lft forever
pi@raspberrypi ~/bacnet-stack-0-8-0 $ ip r
default via 192.168.1.1 dev wlan0
default via 192.168.1.1 dev wlan0  metric 303
192.168.1.0/24 dev wlan0  proto kernel  scope link  src 192.168.1.173  metric 303
pi@raspberrypi ~/bacnet-stack-0-8-0 $ ip n
192.168.1.201 dev wlan0 lladdr b8:76:3f:69:31:95 REACHABLE
192.168.1.10 dev wlan0 lladdr 90:e6:ba:58:1b:40 REACHABLE
192.168.1.1 dev wlan0 lladdr 78:24:af:ed:b7:58 STALE
pi@raspberrypi ~/bacnet-stack-0-8-0 $

Code:

[root@devserver ~]# ping 192.168.1.173
PING 192.168.1.173 (192.168.1.173) 56(84) bytes of data.
64 bytes from 192.168.1.173: icmp_seq=1 ttl=64 time=2.24 ms
64 bytes from 192.168.1.173: icmp_seq=2 ttl=64 time=1.31 ms
^C
--- 192.168.1.173 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1150ms
rtt min/avg/max/mdev = 1.318/1.779/2.241/0.463 ms
[root@devserver ~]# arp -a
raspberrypi (192.168.1.173) at 00:0f:60:06:f5:43 [ether] on wlan0
router.asus.com (192.168.1.1) at 78:24:af:ed:b7:58 [ether] on wlan0
IAMMICHAEL-PC (192.168.1.10) at 90:e6:ba:58:1b:40 [ether] on wlan0
? (192.168.1.199) at 00:0f:60:06:f5:43 [ether] on wlan0
[root@devserver ~]# ping 192.168.1.199
PING 192.168.1.199 (192.168.1.199) 56(84) bytes of data.
64 bytes from 192.168.1.199: icmp_seq=1 ttl=64 time=1.32 ms
64 bytes from 192.168.1.199: icmp_seq=2 ttl=64 time=1.32 ms
^C
--- 192.168.1.199 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1262ms
rtt min/avg/max/mdev = 1.320/1.324/1.328/0.004 ms
[root@devserver ~]# arp -a
raspberrypi (192.168.1.173) at 00:0f:60:06:f5:43 [ether] on wlan0
router.asus.com (192.168.1.1) at 78:24:af:ed:b7:58 [ether] on wlan0
IAMMICHAEL-PC (192.168.1.10) at 90:e6:ba:58:1b:40 [ether] on wlan0
? (192.168.1.199) at 00:0f:60:06:f5:43 [ether] on wlan0
[root@devserver ~]#


NotionCommotion 12-17-2015 10:44 AM

Quote:

Originally Posted by swampthing001 (Post 5465505)
well you can ping it. is it the machine you pinged the pi from?

I am pinging the pi from another machine with ip 192.168.1.201.

NotionCommotion 12-17-2015 10:46 AM

Quote:

Originally Posted by erik2282 (Post 5465506)
What machine provides your DNS, your wireless router? check in its DHCP tables for these IP's and hostnames, may need to clear or correct entries.

Yes, I believe it is my wireless router. I looked in its DHCP tables, and it appears to be the correct 192.168.1.199. I'll try rebooting the router to see what happens. Over and out...

NotionCommotion 12-17-2015 02:21 PM

Dang, this is frustrating!

So, if I log onto my router, it shows both eth0 and wlan0 as being DHCP and not static. I want them to be static.

Furthermore, if I reboot my router, I am not able to PuTTY into the device (at least using what I assumed were its static IPs) until I restart it.

So, while I thought I had set it up with static IPs, it appears I haven't.

Below is my config.

Is there a way to confirm whether it is set up with a static IP or not? When searching for answers, all I saw was "Look at /etc/network/interfaces", and that gets me nowhere.

Thanks in advance for any help or suggestions.


Code:

pi@raspberrypi ~ $ cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
#iface eth0 inet manual
iface eth0 inet static
address 192.168.1.198
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
network 192.168.1.0

auto wlan0
allow-hotplug wlan0
#iface wlan0 inet manual
iface wlan0 inet static
address 192.168.1.199
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
network 192.168.1.0
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

#auto wlan1
#allow-hotplug wlan1
#iface wlan1 inet manual
#wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

pi@raspberrypi ~ $


EDIT. Also, if I restart the network, I lose communication and need to reboot the machine.
Code:

pi@raspberrypi ~ $ sudo /etc/init.d/networking restart
[warn] Running /etc/init.d/networking restart is deprecated because it may not re-enable some interfaces ... (warning).
[....] Reconfiguring network interfaces...
wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1
RTNETLINK answers: File exists
Failed to bring up wlan0.
ifup: interface eth0 already configured
done.
pi@raspberrypi ~ $


swampthing001 12-17-2015 03:52 PM

It looks right from what I can tell. You define a static IP on the machine and not the router. This breaks down the process of setting up a static IP on eth0 http://www.modmypi.com/blog/tutorial...tic-ip-address and this post is pretty spot on with establishing a static IP on wlan0 http://www.electroschematics.com/949...-raspberry-pi/ And this one too https://www.raspberrypi.org/forums/v...p?f=91&t=22660

NotionCommotion 12-17-2015 04:50 PM

I agree it looks right, but why would the router show it as being DHCP? Is there any commands which would confirm?

berndbausch 12-17-2015 06:39 PM

First, I am a bit confused - your Raspberry Pi is not the same as the router, correct? If so:

It's absolutely normal to have more than one IP address on an interface. ifconfig is too old for such things, that's why you should retire it and use the ip command instead.

You can, for example, add an IP address manually:
Code:

# ip a add 1.2.3.4/11 dev wlan0    # add a bogus address to wlan0
# ip a show dev wlan0              # verify the new configuration of wlan0
# ip a del 1.2.3.4/11 dev wlan0    # delete the address

The question is where 192.168.1.173 comes from. I don't know anything about WiFi configuration, but I would suspect that the answer is in both your router configuration and the line "wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf" in the interfaces file.

The fact that your router is configured differently than your Raspberry simply means that you didn't configure it correctly (in my humble opinion - again, I don't know too much about wireless LAN configuration).

JeremyBoden 12-17-2015 08:09 PM

Your Pi only has one ethernet connection - but you are defining two ethernet connections for it.

When it comes up, entering
Code:

arp -n
might reveal something of interest about your arp cache.

NotionCommotion 12-18-2015 06:52 AM

Thanks berndbausch,

The Raspberry Pi is not the same as the router.

Why is it absolutely normal to have more than one IP address on an interface? Is it primarily to support virtual servers?

I ended up deleting the second IP, and think I have it resolved.
Code:

update-rc.d dhcpcd disable
service dhcpcd stop
ip addr del 192.168.1.173/24 dev eth0



All times are GMT -5. The time now is 10:59 AM.