0

This is from How can I set mac address using the command line in Ubuntu 16.04? , where I cannot contact the_velour_fog

I have this same problem but im stuck with the solution adonis proposed:

nmcli connection modify --temporary 802-11-wireless.cloned-mac-address 00:60:1B:EB:F8:73

Is this a command? What do I write instead of connection_name? I don't know where to find it.

nmcli connection up

If this is a whole command, do I && between them?

salvia
  • 41

2 Answers2

2

Yes, "nmcli" is a command. It's a shortened version of NetworkManager command-line interface. You can find it by using the "which" command, like this (but it should already be in your PATH)

[jcall@laptop ~]$ which nmcli
/usr/bin/nmcli

The 'connection name' will be something you created previously. Your connections could be created from the command-line, but I usually just use the GUI to create them (especially wireless connections.) You can list your connections with the command "nmcli connection show" or the abbreviated way "nmcli c s" Here is an example of my connections...

[jcall@laptop ~]$ nmcli connection show
NAME              UUID                                  TYPE             DEVICE 
Home_WiFi         c1c95bd9-78f3-4764-9922-971339702735  802-11-wireless  --     
Hotel_WiFi        921ad0bf-e18e-4d90-87d9-0f1c852c3dc7  802-11-wireless  --     
Google Starbucks  d5242485-ebd6-4152-a839-eaedacc49b4a  802-11-wireless  --     
enp0s25           6c6036d5-4739-3540-ac21-bf7a04669ed6  802-3-ethernet   --     

Finally, you need to execute the commands in order, one after the other. You could use && to do that, if you want to create a long single-line command. I usually just create a small script file to make things easier. Here is my example.

[jcall@laptop ~]$ cat ~/bin/mac-changer.sh 
#!/bin/bash

DEV=wlp3s0
NEWMAC=9c:d9:17:2e:ae:5f

if [ $# -lt 1 ]
then
  echo "You forgot to tell me which network to connect to..."
  echo "Please run \`nmcli con show\` for ideas..."
  exit 1
fi

if $(nmcli -t -f NAME con show | grep -q $1)
then
  nmcli connection modify --temporary $1 802-11-wireless.cloned-mac-address $NEWMAC
  nmcli connection up $1
else
  echo "Error: $1 is not a known network.  Please run \`nmcli con show\` for ideas..."
fi
-1

You can either do a one whole command with && or in order. < Connection name > is the name of the wifi you are currently connected too. You dont have to input <> just the string name ex. MyWifi

ljay
  • 1