Chapter 4. Configuring MACsec

The following section provides information on how to configure Media Control Access Security (MACsec), which is an 802.1AE IEEE standard security technology for secure communication in all traffic on Ethernet links.

4.1. Introduction to MACsec

Media Access Control Security (MACsec, IEEE 802.1AE) encrypts and authenticates all traffic in LANs with the GCM-AES-128 algorithm. MACsec can protect not only IP but also Address Resolution Protocol (ARP), Neighbor Discovery (ND), or DHCP. While IPsec operates on the network layer (layer 3) and SSL or TLS on the application layer (layer 7), MACsec operates in the data link layer (layer 2). Combine MACsec with security protocols for other networking layers to take advantage of different security features that these standards provide.

4.2. Using MACsec with nmcli tool

This procedure shows how to configure MACsec with nmcli tool.


  • The NetworkManager must be running.
  • You already have a 16-byte hexadecimal CAK ($MKA_CAK) and a 32-byte hexadecimal CKN ($MKA_CKN).


  1. To add new connection using nmcli, enter:

    ~]# nmcli connection add type macsec \
      con-name test-macsec+ ifname macsec0 \
      connection.autoconnect no \
      macsec.parent enp1s0 macsec.mode psk \
      macsec.mka-cak $MKA_CAK \
      macsec.mka-ckn $MKA_CKN

    Replace macsec0 with the device name you want to configure.

  2. To activate the connection, enter:

    ~]# nmcli connection up test-macsec+

After this step, the macsec0 device is configured and can be used for networking.

4.3. Using MACsec with wpa_supplicant

This procedure shows how to enable MACsec with a switch that performs authentication using a pre-shared Connectivity Association Key/CAK Name (CAK/CKN) pair.


  1. Create a CAK/CKN pair. For example, the following command generates a 16-byte key in hexadecimal notation:

    ~]$ dd if=/dev/urandom count=16 bs=1 2> /dev/null | hexdump -e '1/2 "%02x"'
  2. Create the wpa_supplicant.conf configuration file and add the following lines to it:

        mka_cak=0011... # 16 bytes hexadecimal
        mka_ckn=2233... # 32 bytes hexadecimal

    Use the values from the previous step to complete the mka_cak and mka_ckn lines in the wpa_supplicant.conf configuration file.

    For more information, see the wpa_supplicant.conf(5) man page.

  3. Assuming you are using wlp61s0 to connect to your network, start wpa_supplicant using the following command:

    ~]# wpa_supplicant -i wlp61s0 -Dmacsec_linux -c wpa_supplicant.conf