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:
nmcli con down id "Wired connection 1"
works as with automatic connection disabled (but again that's not an option),- I don't want to use
sudo
(wouldn't be good to implement in a script!).
Best Answer
The following command works for me like a charm if I want to disable any internet connection from terminal:
To enable it again:
NOTE: As commented by CPBL, this no longer works in Ubuntu 15.04 and later. Instead use
nmcli networking off
andnmcli networking on
.Another way very close to your quest is to use:
To enable eth0 again you need to type:
Example for connection named "Wired connection 1":
Change
eth0
to your wired interface name. This will prevent any further connections without user/manual intervention asman nmci
says:Please read
man nmcli
for more info.