Linux uses NetworkManager to randomly generate your MAC address

Linux uses NetworkManager to randomly generate your MAC address

Nowadays, whether you are on the sofa at home or in a coffee shop outside, as long as you turn on your laptop and connect to Wi-Fi, you can stay connected with the outside world through the Internet. But most of today's Wi-Fi hotspots can track your device through the unique MAC address corresponding to each network card. Here’s how to avoid being tracked.
Now many people have begun to pay attention to the issue of personal privacy. The issue of personal privacy does not just refer to preventing others from accessing the private content on your computer (which is another issue), but more to legibility, that is, whether it can be easily counted and tracked. Everyone should pay more attention to this. At the same time, the bottom line in this regard is that service providers can only track users after obtaining authorization from users. For example, the timed Wi-Fi at an airport can only be used after user authorization.
Because fixed MAC addresses can be easily traced, they should be changed regularly. A random MAC address is a good choice. Since MAC addresses are generally only used within a local area network, random MAC addresses are unlikely to cause conflicts.

Introduction to NetworkManager

NetworkManager consists of a background service that manages the system's network connections and reports their status over D-BUS (a free software project that provides a simple way for applications to communicate with each other. It was developed as part of the freedesktoporg project.) and a client program that allows users to manage network connections.
NetworkManager Service: NetworkManager - Linux Networking made Easy
Advantages of NetworkManager: Simplifies the work of network connections and makes the desktop itself and other applications aware of the network.
NetworkManager's background service: for GNOME and Xfce it is the nm-applet tool, and for KDE users it is KNetworkManager.
Early versions of NetworkManager (formerly known as NetworkMangler) were not very convenient to use, but now it has become a powerful tool that makes managing networks no longer painful.

Improvements and new features in the latest version of NetworkManager

The new version of NetworkManager supports more network devices. Starting from 0.8.1, ModemManager support for mobile broadband devices such as GSM, UMTS and CDMA cards has been added. There are also new features using ModemManager, such as signal strength display and the ability to select 2G/3G mode. You can also turn off roaming to avoid extra connection charges;
NetworkManager 0.8.1 and later also supports the use of Bluetooth, not only supporting Personal Area Network (PAN) Internet access, but also supporting the old Bluetooth Dial-Up Networking (DUN) protocol. All (or most) supported devices can be found on the wiki;
NetworkManager supports automatic configuration and static IP for IPv6; the new version of NetworkManager will also bring DHCP support for IPv6
The new version of NetworkManager enhances the support of devices and protocols. The latest version of NetworkManager has a brand new and beautiful client interface.
Command Line Interface: The biggest feature of the latest version of NetworkManager: Command Line Tool Command, a command line interface for NetworkManager.
NetworkManager has its own CLI tool: nmcli. Using nmcli users can query the status of network connections and can also use it for management. Pros: Primitive; relatively simple syntax; easy to master using NetworkManager in the CLI.

Configuring NetworkManager

To use random MAC addresses for all Wi-Fi connections by default, create the file /etc/NetworkManager/conf.d/00-macrandomize.conf:

[device]
wifi.scan-rand-mac-address=yes
[connection]
wifi.cloned-mac-address=stable
ethernet.cloned-mac-address=stable
connection.stable-id=${CONNECTION}/${BOOT}

Then restart NetworkManager:

systemctl restart NetworkManager

In the above configuration file, by setting the value of cloned-mac-address to stable, the same MAC address is generated each time NetworkManager activates the connection, but a different MAC address is used when connecting. If you want to obtain a random MAC address each time you activate a connection, you need to set the value of cloned-mac-address to random.

Set it to stable to obtain the same IP address from DHCP, and also let the Wi-Fi captive portal remember your login status based on the MAC address. If set to random, you will need to re-authenticate (or click "I agree") every time you connect. This random mode is required when using airport Wi-Fi. Detailed instructions for configuring a specific connection from the terminal using nmcli can be found in this NetworkManager blog post.

Use the ip link command to view the current MAC address. The MAC address will be displayed after the word ether.

$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp2s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
link/ether 52:54:00:5f:d5:4e brd ff:ff:ff:ff:ff:ff
3: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
link/ether 52:54:00:03:23:59 brd ff:ff:ff:ff:ff:ff

When not to randomize MAC addresses

In some cases it does need to be traceable. For example, in a home network, you may need to configure the router to assign consistent IP addresses to computers for port forwarding; for another example, your employer may need to provide Wi-Fi services based on MAC addresses, in which case tracking is required. To change a specific Wi-Fi connection, use nmcli to view the NetworkManager connection and display the current settings:

$ nmcli c | grep wifi
Amtrak_WiFi 5f4b9f75-9e41-47f8-8bac-25dae779cd87 wifi --
StaplesHotspot de57940c-32c2-468b-8f96-0a3b9a9b0a5e wifi --
MyHome e8c79829-1848-4563-8e44-466e14a3223d wifi wlp1s0
...
$ nmcli c show 5f4b9f75-9e41-47f8-8bac-25dae779cd87 | grep cloned
802-11-wireless.cloned-mac-address: --
$ nmcli c show e8c79829-1848-4563-8e44-466e14a3223d | grep cloned
802-11-wireless.cloned-mac-address: stable

This example uses a completely random MAC address at Amtrak (using the default configuration) and a permanent MAC address at MyHome (using the stable configuration). The permanent MAC address is assigned to the network interface when the hardware is manufactured. Network administrators can view the manufacturer ID of the device based on the permanent MAC address.

Change the configuration and reconnect the active interface:

$ nmcli c modify 5f4b9f75-9e41-47f8-8bac-25dae779cd87 802-11-wireless.cloned-mac-address random
$ nmcli c modify e8c79829-1848-4563-8e44-466e14a3223d 802-11-wireless.cloned-mac-address permanent
$ nmcli c down e8c79829-1848-4563-8e44-466e14a3223d
$ nmcli c up e8c79829-1848-4563-8e44-466e14a3223d
$ ip link
...

You can also install NetworkManager-tui to edit connections through a visual interface menu.

When you're walking on the road, you need to be aware of your surroundings and be alert to possible dangers. Likewise, be mindful of your own traceability when using public Internet resources.

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Five Linux server distributions worth choosing in 2018
  • How to Choose a Linux Distribution in 2016
  • How to achieve coexistence of different Linux operating system distributions
  • Basic knowledge of Linux distributions and installation
  • Use iptables and firewalld tools to manage Linux firewall connection rules
  • Detailed explanation of Linux server status and performance related commands
  • How to Run a Command at a Specific Time in Linux
  • Installation of python2.7.10 under Linux system (CentOS)
  • Autotrash tool for Linux to automatically delete old junk files at a scheduled time
  • Python 3.6.1 environment configuration tutorial under Linux
  • An audio-visual Linux distribution that appeals to audiophiles

<<:  Solution to the problem that MySQL service cannot be stopped or deleted under Windows

>>:  jQuery implements clicking left and right buttons to switch pictures

Recommend

Tips for making web table frames

<br />Tips for making web table frames. ----...

How to build a DHCP server in Linux

Table of contents 1. Basic knowledge: 2. DHCP ser...

A brief discussion on two methods to solve space-evenly compatibility issues

Since its launch in 2009, flex has been supported...

Installation and use of Ubuntu 18.04 Server version (picture and text)

1 System Installation Steps OS Version:1804 Image...

display:grid in CSS3, an introduction to grid layout

1. Grid layout (grid): It divides the web page in...

Understand the principles and applications of JSONP in one article

Table of contents What is JSONP JSONP Principle J...

JavaScript to achieve stair rolling special effects (jQuery implementation)

I believe everyone has used JD. There is a very c...

Detailed steps for installing MinIO on Docker

Table of contents 1. Check whether the docker env...

The Complete Guide to Grid Layout in CSS

Grid is a two-dimensional grid layout system. Wit...

What is MIME TYPE? MIME-Types type collection

What is MIME TYPE? 1. First, we need to understand...

How to install phabricator using Docker

I am using the Ubuntu 16.04 system here. Installa...

Why Use DOCTYPE HTML

You know that without it, the browser will use qui...

MySQL query statement grouped by time

MySQL query by year, month, week, day group 1. Qu...

Detailed installation and configuration of Subversion (SVN) under Ubuntu

If you are a software developer, you must be fami...