Skip to content
Advertisement

Programatically activate and deactivate network interfaces using nmcli

I wrote a script that deactivates all the interfaces available using nmcli commands such as:

for iface in `(nmcli -f GENERAL dev list 2>/dev/null || nmcli -f GENERAL dev show) | grep 'GENERAL.DEVICE' | awk '{print $2}'`
do
    nmcli dev disconnect iface $iface
done

I would now like to reactivate these interfaces; there is no nmcli dev connect iface … command, and I’m stuck. In particular, my problem is to reactivate the Ethernet interface.

Thanks in advance for your help!

Advertisement

Answer

Use this command:

nmcli -p con up id "interface name" iface eth0

You can also use uuid instead of id.

-p is just for human readable output and can be ignored.

iface eth0 can also be omitted.

Take a look here for more information.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement