-1

I've configured my Raspberry Pi for static IP. My /etc/network/interfaces looks like this:

auto lo
iface lo inet loopback

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

Yet for some strange reason, every time I reboot my Pi or my router, my Pi gets the requested IP (192.168.1.2) but ALSO a DHCP address (192.168.1.18). So my Pi has two addresses.

Of course, this isn't necessarily a problem, I just think it's strange. Am I doing something wrong? Or not enough? My router is almost completely locked down for management, but I can enter static IPs for devices - is this necessary, if I configure the Pi to do it?

The dynamic address isn't apparent in ifconfig:

eth0      Link encap:Ethernet  HWaddr b8:27:eb:5d:87:71
          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:236957 errors:0 dropped:34 overruns:0 frame:0
          TX packets:260738 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:35215632 (33.5 MiB)  TX bytes:70023369 (66.7 MiB)

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:27258 errors:0 dropped:0 overruns:0 frame:0
          TX packets:27258 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3397312 (3.2 MiB)  TX bytes:3397312 (3.2 MiB)

yet I can ping, ssh and everything on .18 as well.

OZ1SEJ
  • 399
  • 1
  • 5
  • 14

2 Answers2

1

The IP address attached to interface eth0 can be viewed by ip addr. May be eth0 has two IP address configured 192.168.1.2 and 192.168.1.18.

Also you can add multiple IP address to interface eth0 through

sudo ip addr add <IP address> dev eth0

If you dont want IP address 192.168.1.18 you can remove it by

sudo ip addr del 192.168.1.18 dev eth0
Jobin
  • 6,506
  • 5
  • 24
  • 26
1

Since you can add multiple IP addresses to the interface eth0 as noted above, I believe the solution to your problem is to remove the auto eth0 line from your /etc/network/interfaces file.

RC Howe
  • 509
  • 3
  • 16
  • Yeah, obviously it's the auto eth0. Didn't see that at the time. Sorry for the late response, but I thought better late than never... – OZ1SEJ Jun 15 '18 at 10:55