2

I want to assign a static IP address for the eth0 interface without the DHCP allocating a dynamic address. i tried setting the method to manual but that did not help and i end up with 2 IPs on the interface one static and the other is dynamic. i want to have only one static IP on the interface using nmcli

/etc/NetworkManager/system-connections/static.nmconnection:

[connection]
id=static
uuid=5da74c14-d9da-4e15-90c9-5f37913d5610
type=ethernet
interface-name=eth0
permissions=
timestamp=1584007539

[ethernet]
mac-address-blacklist=

[ipv4]
address1=172.17.1.222/24,172.17.0.1
dns=172.17.0.221;172.17.0.220;
dns-search=
method=manual

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=ignore

ip a:

eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether dc:a6:32:3b:22:03 brd ff:ff:ff:ff:ff:ff
inet 172.17.1.222/24 brd 172.17.1.255 scope global noprefixroute eth0
   valid_lft forever preferred_lft forever
inet 172.17.12.14/16 brd 172.17.255.255 scope global dynamic noprefixroute eth0
   valid_lft 602857sec preferred_lft 527257sec
inet6 fe80::dea6:32ff:fe3b:2203/64 scope link 
   valid_lft forever preferred_lft forever
HAK
  • 23
  • 1
  • 4

1 Answers1

2

To configure setting up a static IP configuration and disabling DHCP with nmcli, try running this as root:

nmcli con mod eth0 ipv4.addresses "172.17.1.222/24"
nmcli con mod eth0 ipv4.gateway "172.17.0.1"
nmcli con mod eth0 ipv4.dns "172.17.0.221 172.17.0.220"
nmcli con mod eth0 ipv4.method manual
nmcli con mod eth0 connection.autoconnect yes

Then either reboot your computer or restart network-manager with

systemctl restart NetworkManager
  • 2
    Thanks a lot, The settings worked, but to apply it use `nmcli con up eth0` you dont need to reboot or restart the service. – HAK Mar 12 '20 at 10:50
  • Does this also work if you don't set a gateway as in your original post? Because I suffer from the exact same behaviour... – TylerDurden Apr 05 '20 at 10:12