// Module included in the following assemblies:
//
// * networking/metallb/about-advertising-ipaddresspool.adoc

:_mod-docs-content-type: PROCEDURE
[id="nw-metallb-configure-with-L2-advertisement_{context}"]
= Configuring MetalLB with an L2 advertisement

[role="_abstract"]
You can configure MetalLB so that the `IPAddressPool` is advertised with the L2 protocol.

.Prerequisites

* Install the {oc-first}.
* Log in as a user with `cluster-admin` privileges.
* Install the MetalLB Operator and start MetalLB.

.Procedure

. Create an IP address pool.
+
.. Create a file, such as `ipaddresspool.yaml`, with content like the following example:
+
[source,yaml]
----
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  namespace: metallb-system
  name: doc-example-l2
spec:
  addresses:
    - <ip_address_range>
  autoAssign: false
----
+
--
* `<ip_address_range>` specifies a range of IP addresses that are routable on your network, for example `4.4.4.0/24`.
--
+
.. Apply the configuration for the IP address pool:
+
[source,terminal]
----
$ oc apply -f ipaddresspool.yaml
----

. Create an L2 advertisement.
+
.. Create a file, such as `l2advertisement.yaml`, with content like the following example:
+
[source,yaml]
----
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: l2advertisement
  namespace: metallb-system
spec:
  ipAddressPools:
   - doc-example-l2
----
+
.. Apply the configuration:
+
[source,terminal]
----
$ oc apply -f l2advertisement.yaml
----

.Verification

. Verify that the IP address pool is created:
+
[source,terminal]
----
$ oc get ipaddresspool -n metallb-system
----
+
The following is example output:
+
[source,terminal]
----
NAME             AUTO ASSIGN   AVOID BUGGY IPS   ADDRESSES
doc-example-l2   false         false             ["4.4.4.0/24"]
----

. Verify that the L2 advertisement is created:
+
[source,terminal]
----
$ oc get l2advertisement -n metallb-system
----
+
The following is example output:
+
[source,terminal]
----
NAME              IPADDRESSPOOLS     IPADDRESSPOOL SELECTORS   INTERFACES
l2advertisement   ["doc-example-l2"]
----
