Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The connect automatically option is allowed for my wired "Wired connection 1". Disconnecting the connection works when I do it from the panel's Network -> Disconnect menu. But when I do that with command:

nmcli con down id "Wired connection 1"

no sooner than it disconnects, the connection is back on.

How does Network -> Disconnect work? Could we do the same with nmcli without disabling the automatic connection?

Note:

  1. nmcli con down id "Wired connection 1" works as with automatic connection disabled (but again that's not an option),
  2. sudo is not pereferred (wouldn't be good to implement in a script!).
share|improve this question
    
Maybe this will help. This also worked for me. [Here][1] [1]: askubuntu.com/questions/276822/… –  user258557 Mar 15 at 16:37
    
Yes that's a way.. but I don't want to to run a command with raised privilege.. –  rusty Mar 15 at 16:41

1 Answer 1

up vote 7 down vote accepted

The following command works for me like a charm if I want to disable any internet connection from terminal:

nmcli nm enable false

To enable it again:

nmcli nm enable true

Another way very close to your quest is to use:

nmcli dev disconect iface eth0

Change eth0 with your appropriate wired device name. This will prevent any further connections without user/manual intervention as man nmci says:

          disconnect iface <iface> [--nowait] [--timeout <timeout>]
                 Disconnect a device and prevent the device from automati‐
                 cally activating further connections without user/manual
                 intervention.

                 Available options are:

                 --nowait     – exit immediately without waiting for com‐
                              mand completion

                 --timeout    – how long to wait for command completion
                              (default is 10 s)

Please read man nmcli for more info.

share|improve this answer
    
nmcli nm enable false is very different from what Network -> Disconnect option does.. the latter just disables the specified connection (no elevated privileges required), but the former disables networking! –  rusty Mar 15 at 16:46
    
@rusty well, by disabling networking, you are sure that your internet connection is disabled. If this is not what you asked, please clarify your question. –  Radu Rădeanu Mar 15 at 16:49
    
I'm looking to disable a particular connection but not the network itself.. –  rusty Mar 15 at 16:58
    
@rusty Pease see my new edits. –  Radu Rădeanu Mar 15 at 17:10
    
..nmcli dev disconnect iface eth0 is the one; it disconnects the active connection (say "Wired connection 1") configured to use the device eth0.. and following that I can use nmcli con up id "Wired connection 2" to connect with it's another configuration.. (with nmcli nm enable false that would take nmcli nm enable true && nmcli con up id "Wired connection 2") –  rusty Mar 15 at 17:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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