Jump to content

Enable private ip address for eth0


Go to solution Solved by Zhang Yuming,

Recommended Posts

Hello everyone, I'm using SBC Rockpi4b running the Armbian system. I encountered a problem when using the Ethernet port. I connected the SBC to my laptop via an ethernet cable directly, just like what I did with the RaspberryPi.  while playing with RaspberryPi (Raspbian OS) I can get the ethernet connected, the ip address is set to 168.254.xxx.xxx, i.e., private address. then I can successfully ping the RaspberryPi's ip address in my PC. while playing with the SBC (Armbian OS), the network manager seems to keep waiting a DHCP server repeatedly; and after a while (around 40 seconds) it pops up saying the ethernet disconnected; the only way I can make it connected is to set static ip addresses, but it's not the proper solution.

After googling for days I realized that the two OS (Raspbian vs Armbian) run different programs for the DHCP. Raspbian apply dhcpcd, Armbian apply NetworkManager. so the first idea came to my mind was using the dhcpcd in Armbian. I have learnt that the NetworkManager can specify to use the dhcpcd as dhcp client. I followed some tutorials: 1. installing dhcpcd (sudo apt-get install dhcpcd5); 2. modifying the /etc/NetworkManager/NetworkManager.conf to add: 

[main]
dhcp=dhcpcd

it seems work at the beginning, I can see a 169.254.xxx.xxx ip address in the "ifconfig" output, but after a while it was destroyed. I checked the two services' status:

pi@192.168.0.108:~$ sudo systemctl status dhcpcd
● dhcpcd.service - DHCP Client Daemon
     Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-07-11 14:32:17 CST; 6min ago
       Docs: man:dhcpcd(8)
    Process: 861 ExecStart=/usr/sbin/dhcpcd (code=exited, status=0/SUCCESS)
   Main PID: 1128 (dhcpcd)
      Tasks: 1 (limit: 4461)
     Memory: 968.0K
     CGroup: /system.slice/dhcpcd.service
             └─1128 /usr/sbin/dhcpcd

Jul 11 14:33:25 rockpi-4b dhcpcd[1128]: eth0: adding address fe80::3eb:def9:d81e:17aa
Jul 11 14:33:25 rockpi-4b dhcpcd[1128]: ipv6_addaddr1: Permission denied
Jul 11 14:33:26 rockpi-4b dhcpcd[1128]: eth0: soliciting a DHCP lease
Jul 11 14:33:26 rockpi-4b dhcpcd[1128]: eth0: soliciting an IPv6 router
Jul 11 14:33:31 rockpi-4b dhcpcd[1128]: eth0: probing for an IPv4LL address
Jul 11 14:33:35 rockpi-4b dhcpcd[1128]: eth0: using IPv4LL address 169.254.39.239
Jul 11 14:33:35 rockpi-4b dhcpcd[1128]: eth0: adding route to 169.254.0.0/16
Jul 11 14:33:51 rockpi-4b dhcpcd[1128]: eth0: deleted route to 169.254.0.0/16
Jul 11 14:33:51 rockpi-4b dhcpcd[1128]: eth0: adding route to 169.254.0.0/16
Jul 11 14:33:51 rockpi-4b dhcpcd[1128]: if_route (ADD): Invalid argument
pi@192.168.0.108:~$ sudo systemctl status NetworkManager
● NetworkManager.service - Network Manager
     Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-07-11 14:32:17 CST; 6min ago
       Docs: man:NetworkManager(8)
   Main PID: 860 (NetworkManager)
      Tasks: 3 (limit: 4461)
     Memory: 13.8M
     CGroup: /system.slice/NetworkManager.service
             └─860 /usr/sbin/NetworkManager --no-daemon

Jul 11 14:34:36 rockpi-4b NetworkManager[860]: <info>  [1657521276.7314] device (eth0): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed')
Jul 11 14:34:36 rockpi-4b NetworkManager[860]: <info>  [1657521276.7344] dhcp4 (eth0): activation: beginning transaction (timeout in 45 seconds)
Jul 11 14:35:21 rockpi-4b NetworkManager[860]: <warn>  [1657521321.6769] dhcp4 (eth0): request timed out
Jul 11 14:35:21 rockpi-4b NetworkManager[860]: <info>  [1657521321.6771] dhcp4 (eth0): state changed unknown -> timeout
Jul 11 14:35:21 rockpi-4b NetworkManager[860]: <info>  [1657521321.6773] device (eth0): state change: ip-config -> failed (reason 'ip-config-unavailable', sys-iface-state: 'ma>
Jul 11 14:35:21 rockpi-4b NetworkManager[860]: <warn>  [1657521321.6828] device (eth0): Activation: failed for connection 'Wired connection 1'
Jul 11 14:35:21 rockpi-4b NetworkManager[860]: <info>  [1657521321.6842] device (eth0): state change: failed -> disconnected (reason 'none', sys-iface-state: 'managed')
Jul 11 14:35:21 rockpi-4b NetworkManager[860]: <info>  [1657521321.7049] dhcp4 (eth0): canceled DHCP transaction
Jul 11 14:35:21 rockpi-4b NetworkManager[860]: <info>  [1657521321.7051] dhcp4 (eth0): state changed timeout -> done
Jul 11 14:35:21 rockpi-4b NetworkManager[860]: <info>  [1657521321.7177] manager: startup complete

It's my first post here, it will be greatly appreciated if anyone could tell me how to make the NetworkManager stop reinitializing the ethernet connection and assign a private ip address (169.254.xxx.xxx) instead?

 

Regards,

Yuming

 

Link to comment
Share on other sites

Open source development is fun. Join Armbian Linux development team today!

10 hours ago, CryBaby said:

Is your PC running a DHCP server?

not exactly, both the PC and the SBC acts as dhcp client. actually there may be two connection cases : one is that the PC and the SBC are connected to a router which has a DHCP server; the other is the PC and the SBC are connected directly.

 

Link to comment
Share on other sites

For direct connection the PC will need to run a DHCP server if you don't want to set a static IP on the SBC. You don't want two DHCP servers on your network so you will have to configure it carefully or disconnect from the router while it is running.

Link to comment
Share on other sites

  • Solution

I found the solution is to disable NetworkManager and Networking, enable the dhcpcd; by this way the ethernet works for me.

sudo systemctl stop NetworkManager
sudo systemctl disable NetworkManager

sudo systemctl stop networking
sudo systemctl disable networking

sudo apt-get install dhcpcd5

the wireless network is disabled by this way, but can be started by wpa_supplicant, it's another topic.

Link to comment
Share on other sites

https://linux.die.net/man/8/avahi-autoipd

 

The 169.254.0.0/16 is a private autoconfigured IP space used for IPv4 Link-Local autoconfiguration.  If you don't have a DHCP server on the local network, then you can't receive a DHCP-assigned address; but you can autoconfigure an IPv4 address.

 

If you want NetworkManager to manage the connection, you need to tell NetworkManager that it isn't expecting a DHCP address, but only a link-local one.

in /etc/NetworkManager/system-connections/*.nmconnection:

 [ipv4]

 method=link-local

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...