How to change eth0 ip address

Hello, I’m in need to change one IP address on a Pi4 Screenly-OSE because I stuck with the same IP of another devices on the same network, I have try with nmcli con mod eth0 ipv4.addresses 192.168.1.6/24 but I got “Error: unknown connection ‘eth0’”
how can I change it? I’m working on host consolle.
Thanks in advance,
Alessandro

Hi @Niubbo75 , I would normally expect eth0 to be a valid interface name, so, can you run nmcli d and post the results? However, you can set a static IP at runtime, by following these instructions: Network Setup on balenaOS 2.x - Balena Documentation

Hi @dtischler if I run nmcli d:

DEVICE           TYPE      STATE                   CONNECTION         
eth0             ethernet  connected               Wired connection 1 
supervisor0      bridge    connected (externally)  supervisor0        
wlan0            wifi      disconnected            --                 
balena0          bridge    unmanaged               --                 
br-5fbcba12d7f1  bridge    unmanaged               --                 
resin-dns        bridge    unmanaged               --                 
veth9c703dd      ethernet  unmanaged               --                 
veth9d7be1d      ethernet  unmanaged               --                 
vetha21960d      ethernet  unmanaged               --                 
vetha675c77      ethernet  unmanaged               --                 
vethacd8b6b      ethernet  unmanaged               --                 
vethcfae860      ethernet  unmanaged               --                 
vetheb43616      ethernet  unmanaged               --                 
lo               loopback  unmanaged               --                 
resin-vpn        tun       unmanaged               -- 

and I got eth0 but if I run

nmcli con mod eth0 ipv4.addresses 192.168.1.6/24

I still get the error mentioned before, it is a really strange behaviour.

ATM I had solved setting a static IP in connection file (as per the link you post here).
BTW that device is still offline right now, but if I connect to another device in the same network I can ping it via IP, so I’m thinking that maybe there is another device with the same IP address on the network and they conflicts, I had try to ssh into it but I got connection refused.

Thanks for your support, best regards,
Alessandro

Hi,

I think there is some confusion here between the device and the connection in NetworkManager.

The connection usually holds the IP address and other configuration that a device could need to connect to a network.
According to your table, the device “eth0” is currently using the connection “Wired connection 1”.

The command you are running is trying to change a connection, not a device.
So your command would become nmcli con mod "Wired Connection 1" ipv4.addresses 192.168.1.6/24 .
I believe it will only pick up this new address when reconnecting the device to the connection.

You could also set the configuration on the device by using the command nmcli dev mod eth0 ipv4.addresses 192.168.1.6/24, in which case it should be effective immediately.

1 Like

@TJvV thanks for the clarification!
Best regards,
Alessandro

@TJvV I’ve try right now but if I use nmcli dev mod eth0 ipv4.address 192.168.1.200/24 I add another IP to eth0 but I still have in use the old ip (192.168.1.5).

Now I have this:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq qlen 1000
    link/ether dc:a6:32:a7:da:61 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.5/24 brd 192.168.1.255 scope global dynamic eth0
       valid_lft 85505sec preferred_lft 85505sec
    inet 192.168.1.200/24 brd 192.168.1.255 scope global secondary eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::f69e:4292:7799:de1e/64 scope link 
       valid_lft forever preferred_lft forever

How should I set 192.168.1.200 as default and remove the other?
Best regards,
Alessandro

Hi,

The device should take the settings from the connection, if you’re seeing both addresses, I’m guessing the first one was obtained by DHCP.
With NetworkManager you can tell your connection to use DHCP by setting connection.ipv4.method to auto.
It will then add the contents of connection.ipv4.addresses as alternative addresses.
If you really want only the one address, you need to disable DHCP, by changing connection.ipv4.method to manual.

Note that for your device there is no real penalty to having multiple addresses.

If you want to know more, you can find all the settings here.

Also, if you run into cases where the changes to your connection are not properly applied to your device, you can run nmcli dev reapply eth0 to reconfigure the device.

2 Likes

Thank you @TJvV for your support. You rock!

@Niubbo75 let us know if that works for you!

1 Like