Raspberry Pi 2 install two ip's?

#1

Maybe normal but I’m not familiar with this so asking…

I recently flashed an sd and booted up the minimal image and this is my ip addr return:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether b8:27:eb:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.xxx/24 brd 192.168.0.255 scope global dynamic eth0
       valid_lft 4860sec preferred_lft 4860sec
    inet 192.168.0.xxx/24 brd 192.168.0.255 scope global secondary noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::7832:xxxx:xxxx:xxxx/64 scope link 
       valid_lft forever preferred_lft forever

As presented there are two ip’s assigned to eth0. Second is marked secondary and has a forever lease (I think) while first one looks to have about a 90min lease.

I’m asking because I plan on running a simple apache server and would like to ensure I’m using the correct ip to connect things to my device. My best guess is maybe a secondary static ip?

#2

Yes it looks like it. The first one seems to be a IP your PI received form a DHCP Server in your Network. Static IP’s usually don’t have a life time other than forever.

Did you set up a static IP? Because it is not normal that your PI just have a static IP. If you set up a static IP you might want to disable the DHCP client. But you can use both if you want.

#3

I did not, install has only existed for maybe an hour. Only action so far has been to remove manjaro user and create my own.

I do have another RPi running Pi-Hole. However I do not see either ip in the query log.

Edit: Pi-Hole is NOT my dhcp controller, I left that to the router (tplink-1350ac)

#4

I’m not sure if Manjaro ARM uses systemd-networkd, if not you might want to find out wich process sets up your network.

networkctl

and

networkctl status

might show some extra infos (you might need sudo).

journalctl -b -u systemd-networkd
#5

It does.
Manjaro ARM on pi’s run systemd-networkd with DHCP enabled. We don’t set a static IP anywhere.

1 Like
#6

It’s using systemd-networkd however, there’s no mention of setting the second the static ip by that service. I can see that the router assigned the non-static ip. (I removed the -b flag on journalctl command because I did update and reboot, so this log is from the first boot)

[ez@manjaro-arm ~]$ networkctl
IDX LINK             TYPE               OPERATIONAL SETUP     
  1 lo               loopback           carrier     unmanaged 
  2 eth0             ether              routable    configured

2 links listed.
[ez@manjaro-arm ~]$ networkctl status
*        State: routable
       Address: 192.168.0.17x on eth0
                192.168.0.18x on eth0
                fe80::ba27:ebff:fe4a:17a3 on eth0
       Gateway: 192.168.0.1 (TP-LINK TECHNOLOGIES CO.,LTD.) on eth0 `<-- Router`
           DNS: 192.168.0.xxx `<-- RPi Pi-Hole`
[ez@manjaro-arm ~]$ journalctl -u systemd-networkd
-- Logs begin at Tue 2019-01-15 13:47:25 UTC, end at Mon 2019-04-01 18:46:07 UTC. --
Jan 15 13:47:25 manjaro-arm systemd[1]: Starting Network Service...
Jan 15 13:47:25 manjaro-arm systemd-networkd[204]: Configuration file /etc/systemd/network/20-wired.network is marked executable. Please remove executable permission >
Jan 15 13:47:25 manjaro-arm systemd-networkd[204]: Enumeration completed
Jan 15 13:47:25 manjaro-arm systemd[1]: Started Network Service.
Jan 15 13:47:27 manjaro-arm systemd-networkd[204]: eth0: Gained carrier
Jan 15 13:47:27 manjaro-arm systemd-networkd[204]: eth0: DHCPv4 address 192.168.0.17x/24 via 192.168.0.1
Jan 15 13:47:29 manjaro-arm systemd-networkd[204]: eth0: Gained IPv6LL
Jan 15 13:47:41 manjaro-arm systemd-networkd[204]: eth0: Configured
Jan 15 14:38:49 manjaro-arm systemd[1]: Stopping Network Service...
Jan 15 14:38:50 manjaro-arm systemd[1]: systemd-networkd.service: Succeeded.
Jan 15 14:38:50 manjaro-arm systemd[1]: Stopped Network Service.
-- Reboot --
Apr 01 18:10:24 manjaro-arm systemd[1]: Starting Network Service...
Apr 01 18:10:26 manjaro-arm systemd-networkd[208]: Configuration file /etc/systemd/network/20-wired.network is marked executable. Please remove executable permission >
Apr 01 18:10:26 manjaro-arm systemd-networkd[208]: Enumeration completed
Apr 01 18:10:26 manjaro-arm systemd[1]: Started Network Service.
Apr 01 18:10:27 manjaro-arm systemd-networkd[208]: eth0: Gained carrier
Apr 01 18:10:27 manjaro-arm systemd-networkd[208]: eth0: Could not bring up interface: Invalid argument
Apr 01 18:10:28 manjaro-arm systemd-networkd[208]: eth0: Lost carrier
Apr 01 18:10:28 manjaro-arm systemd-networkd[208]: eth0: Gained carrier
Apr 01 18:10:28 manjaro-arm systemd-networkd[208]: eth0: DHCPv4 address 192.168.0.17x/24 via 192.168.0.1
Apr 01 18:10:28 manjaro-arm systemd-networkd[208]: eth0: Gained IPv6LL
Apr 01 18:10:40 manjaro-arm systemd-networkd[208]: eth0: Configured
#7

Ideally, I would keep it and be thankful I didn’t have to do it manually but, I’m wary not knowing how it was assigned…

If I knew more about what was going on; my first thought is to just remove it and see if it is re-assigned (maybe on reboot).

#8

Try that. what is the content of the /usr/lib/systemd/network/eth0.network file?
It might be in /etc/systemd/ instead.

#9

This looks all good. You get a IP form your DHCP, this means you received also a Gateway and a DNS Server. It is normal that the setup of a static IP does not show up in the journal.

It might be interesting to see the content of this file.

#10

Here are the requested contents:

[Match]
Name=eth0

[Network]
DHCP=ipv4 
[ez@manjaro-arm network]$ ls -al
total 12
drwxr-xr-x 2 root root 4096 Jan 28 15:39 .
drwxr-xr-x 5 root root 4096 Jan 15 14:19 ..
-rwxr-xr-x 1 root root   40 Nov 29 17:11 20-wired.network
#11

Maybe NetworkManager also assigns it one?

#12

Ive tried to remove the static ip ($ sudo ip addr del 192.168.0.18x/24 dev eth0) and to flush the interface ($ sudo ip addr flush dev eth0)

Here’s maybe a small catch, I’m running this headless. Logged into the static ip, I ran the above commands to no effect. So I switched to the dhcp provided ip (192.168.0.17x) and tried both commands again. This time it removed the dhcp provided ip and disconnected me however, the static ip still exists.

Hmmm, let me look at that…

#13

I don’t think NetworkManager is up…

[ez@manjaro-arm network]$ systemctl --all|grep -i network                 
  systemd-networkd.service                                                                     loaded    active   running   Network Service                                                                       
  systemd-networkd.socket                                                                      loaded    active   running   Network Service Netlink Socket                                                        
  network-pre.target                                                                           loaded    inactive dead      Network (Pre)                                                                         
  network.target                                                                               loaded    active   active    Network                                                                               
[ez@manjaro-arm network]$ nmcli
-bash: nmcli: command not found
#14

Maybe try

journalctl -g 192.168.0.

Perhaps something with 18X shows up.

With two process trying to get a IP form a DHCP, one usually loses. But even if both are success the second IP should have a lifetime different form forever.

Can your DHCP Server give the 192.168.0.18X range to clients?

#15

I’m pretty sure it can assign up to 254, I have other ip’s that have existed for abt 6 months in the 190’s range.

Output of journalctl -g 192.168.0.:

-- Logs begin at Tue 2019-01-15 13:47:25 UTC, end at Mon 2019-04-01 19:39:20 UTC. --
Jan 15 13:47:27 manjaro-arm systemd-networkd[204]: eth0: DHCPv4 address 192.168.0.17x/24 via 192.168.0.1
Jan 15 13:47:28 manjaro-arm dhcpcd[228]: eth0: offered 192.168.0.18x from 192.168.0.1
Jan 15 13:47:28 manjaro-arm dhcpcd[228]: eth0: probing address 192.168.0.18x/24
Jan 15 13:47:33 manjaro-arm dhcpcd[228]: eth0: leased 192.168.0.18x for 7200 seconds
Jan 15 13:47:33 manjaro-arm dhcpcd[228]: eth0: adding route to 192.168.0.0/24
Jan 15 13:47:33 manjaro-arm dhcpcd[228]: eth0: adding default route via 192.168.0.1
Jan 15 13:49:46 manjaro-arm sshd[290]: Accepted password for manjaro from 192.168.0.12x port 58128 ssh2
Jan 15 13:54:58 manjaro-arm sshd[299]: Received disconnect from 192.168.0.12x port 58128:11: disconnected by user
Jan 15 13:54:58 manjaro-arm sshd[299]: Disconnected from user manjaro 192.168.0.12x port 58128
Jan 15 13:55:10 manjaro-arm sshd[323]: Accepted password for ez from 192.168.0.12x port 59064 ssh2
Jan 15 14:14:56 manjaro-arm sshd[334]: Received disconnect from 192.168.0.12x port 59064:11: disconnected by user
Jan 15 14:14:56 manjaro-arm sshd[334]: Disconnected from user ez 192.168.0.12x port 59064
Jan 15 14:15:03 manjaro-arm sshd[404]: Accepted password for ez from 192.168.0.12x port 33974 ssh2
Jan 15 14:26:22 manjaro-arm sshd[833]: Accepted password for ez from 192.168.0.12x port 35722 ssh2
-- Reboot --
Apr 01 18:10:28 manjaro-arm systemd-networkd[208]: eth0: DHCPv4 address 192.168.0.17x/24 via 192.168.0.1
Apr 01 18:10:29 manjaro-arm dhcpcd[242]: eth0: offered 192.168.0.18x from 192.168.0.1
Apr 01 18:10:29 manjaro-arm dhcpcd[242]: eth0: probing address 192.168.0.18x/24
Apr 01 18:10:34 manjaro-arm dhcpcd[242]: eth0: leased 192.168.0.18x for 7200 seconds
Apr 01 18:10:34 manjaro-arm dhcpcd[242]: eth0: adding route to 192.168.0.0/24
Apr 01 18:10:34 manjaro-arm dhcpcd[242]: eth0: adding default route via 192.168.0.1

and then I have this repeating every 5 secs, I forgot to turn off the script for my local genmon that let’s me know my devices are up and displays their ip’s, will turn that off now.

Apr 01 19:38:15 manjaro-arm sshd[5160]: Accepted publickey for ez from 192.168.0.12x port 52494 ssh2: RSA SHA256:CMAr2Gu2qmyiYHzbV6QIgwpMuKbcJttb92ToLKy+c+g
Apr 01 19:38:15 manjaro-arm sshd[5162]: Received disconnect from 192.168.0.12x port 52494:11: disconnected by user
Apr 01 19:38:15 manjaro-arm sshd[5162]: Disconnected from user ez 192.168.0.12x port 52494
#16

We have a winner.

Now it is time to find out why it was started or which process/service started dhcpcd. Because dhcpcd and systemd-networkd are not good friends.


It looks like the default rp2 image enables dhcpcd.service by default. I’m not sure if this is a good idea.

You might want to disable dhcpcd.service and reboot.

#17

Nice! getting somewhere!

Here’s this output if it helps:

ez@manjaro-arm ~]$ sudo systemctl status dhcpcd
[sudo] password for ez: 
* dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/usr/lib/systemd/system/dhcpcd.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-04-01 18:10:28 UTC; 1h 45min ago
 Main PID: 242 (dhcpcd)
    Tasks: 1 (limit: 2209)
   CGroup: /system.slice/dhcpcd.service
           `-242 /usr/bin/dhcpcd -q -b

Apr 01 19:13:38 manjaro-arm dhcpcd[242]: eth0: adding route to 192.168.0.0/24
Apr 01 19:13:38 manjaro-arm dhcpcd[242]: eth0: adding default route via 192.168.0.1
Apr 01 19:14:05 manjaro-arm dhcpcd[242]: eth0: pid 3299 deleted IP address 192.168.0.18x/24
Apr 01 19:14:05 manjaro-arm dhcpcd[242]: eth0: deleting route to 192.168.0.0/24
Apr 01 19:14:05 manjaro-arm dhcpcd[242]: eth0: deleting default route via 192.168.0.1
Apr 01 19:14:05 manjaro-arm dhcpcd[242]: eth0: rebinding lease of 192.168.x.180
Apr 01 19:14:05 manjaro-arm dhcpcd[242]: eth0: probing address 192.168.0.18x/24
Apr 01 19:14:10 manjaro-arm dhcpcd[242]: eth0: leased 192.168.0.18x for 7200 seconds
Apr 01 19:14:10 manjaro-arm dhcpcd[242]: eth0: adding route to 192.168.0.0/24
Apr 01 19:14:10 manjaro-arm dhcpcd[242]: eth0: adding default route via 192.168.0.1
[ez@manjaro-arm ~]$ sudo systemctl stop dhcpcd
[ez@manjaro-arm ~]$ sudo systemctl disable dhcpcd
Removed /etc/systemd/system/multi-user.target.wants/dhcpcd.service.
[ez@manjaro-arm ~]$ sudo shutdown -r now
Connection to 192.168.0.18x closed by remote host.
Connection to 192.168.0.18x closed.
#18

There was a second DHCP Client running. I never saw that the IP then has a forever lifetime, but maybe systemd-networkd does so magic to this IP.

One of the IP’s should be gone after the reboot.

But now you can set up a second static IP in the systemd-networkd config file.

#19

That did the trick, thank you!

-would like to mark as solution but not seeing the option

#20

I believe it is not possible to mark something as a solution in the “General Discussion” area.