# How to tag vlan on bond using nmcli community

**URL:** <https://forum.ansible.com/t/how-to-tag-vlan-on-bond-using-nmcli-community/3325>\
**Category:** Get Help\
**Tags:** playbook\
**Created:** [January 15, 2024, 9:26pm UTC](https://forum.ansible.com/t/how-to-tag-vlan-on-bond-using-nmcli-community/3325 "2024-01-15T21:26:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomers\_007](https://avatars.discourse-cdn.com/v4/letter/t/cc9497/32.png) [@tomers\_007](https://forum.ansible.com/u/tomers_007)\
**Post date:** [January 15, 2024, 9:26pm UTC](https://forum.ansible.com/t/how-to-tag-vlan-on-bond-using-nmcli-community/3325/1 "2024-01-15T21:26:48Z")

</div>

how to tag vlan on bond using nmcli community

---

<div class="post-metadata">

**Author:** ![atul\_mohan](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@atul\_mohan](https://forum.ansible.com/u/atul_mohan)\
**Post date:** [January 5, 2025, 7:09pm UTC](https://forum.ansible.com/t/how-to-tag-vlan-on-bond-using-nmcli-community/3325/2 "2025-01-05T19:09:57Z")

</div>

```auto
---
- name: Configure VLAN on bond using nmcli
  hosts: your_hosts_here # Replace with your target hosts
  become: yes # This task requires sudo privileges
  tasks:
    - name: Ensure bond0 is configured
      nmcli:
        type: bond
        conn_name: bond0
        ifname: bond0
        mode: 802.3ad
        options:
          miimon: 100
          downdelay: 0
          updelay: 0
        ip4: "{{ '0.0.0.0' }}" # Disables IPv4 on the bond itself
        ip6: "{{ '::' }}"
        state: present

    - name: Add physical interfaces to bond0
      nmcli:
        type: ethernet
        conn_name: "bond0-{{ item }}"
        ifname: "{{ item }}"
        master: bond0
        state: present
      loop:
        - eno1 # Replace with your actual interface names
        - eno2

    - name: Configure VLAN on bond0
      nmcli:
        type: vlan
        conn_name: "bond0.{{ vlan_id }}"
        ifname: "bond0.{{ vlan_id }}"
        dev: bond0
        id: "{{ vlan_id }}"
        ip4: "{{ vlan_ip }}/{{ vlan_mask }}"
        gw4: "{{ vlan_gateway }}"
        state: present
      vars:
        vlan_id: 123 # Change this to your VLAN ID
        vlan_ip: 192.168.123.123 # Change to your desired IP
        vlan_mask: 24
        vlan_gateway: 192.168.123.1 # Change to your network's gateway

    - name: Activate all connections
      nmcli:
        conn_name: "{{ item }}"
        state: up
      loop:
        - bond0
        - bond0-eno1
        - bond0-eno2
        - bond0.123 # Assuming VLAN ID is 123, adjust accordingly

    - name: Verify network configuration
      shell: |
        nmcli connection show
        ip addr show
      register: network_info
      changed_when: false # This task doesn't change system state, just for info

    - name: Display network info
      debug:
        var: network_info.stdout_lines

```
