4

On Ubuntu 14.04, how can I add an Ethernet connection from the command line that's editable in the Network Manager GUI?

I have studied nmcli which is the command line tool for the Network Manager. Unfortunately:

  • If you compare the nmcli tool on Ubuntu 14.04 LTS and that on Ubuntu 15.10 documentation, you'll notice that 14.04 LTS doesn't support adding an Ethernet connection via the nmcli tool. The add command is added to nmcli's connection object since 15.10. It's not available on 14.04.

  • The nmcli on Ubuntu 14.04 LTS can connect to a wireless network (see the last example in its document), but I want to create an Ethernet connection.

  • Although I can edit the file /etc/network/interfaces to add the Ehternet interfaces, they are not visible in the Network Manager, and this is not what I prefer.

I'm doing this because I'm writing a shell script to configure the network, and I also want to allow the users to edit the configuration from the GUI when necessary.

Thanks in advance!

==========

UPDATE #1:

I forgot to mention nm-connection-editor: As far as I can see, it is still a GUI tool and requires the user interaction to create/edit a connection. Because I'm trying to automate the process in a script, I don't want to use any GUI stuff here.

1

You can edit/create a connection file in /etc/NetworkManager/system-connections. For instance I just created ethfix192

[802-3-ethernet]
duplex=full

[connection]
id=ethfix192
type=802-3-ethernet
autoconnect=false

[ipv6]
method=auto

[ipv4]
method=manual
address1=192.168.2.22/24,0.0.0.0

You will see how the lines in this file correspond to the settings in the GUI.

Note: Ensure that the file has permission '600', otherwise NetworkManager will ignore the file.

Afterwards you need to restart NetworkManager (IIRC on 14.04 it was with sudo service NetworkManager restart, or sudo service network-manager restart) and NetworkManager will recognize the connection.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.