how to create bridge on main interface?
- From: Jan Hutař <jhutar redhat com>
- To: networkmanager-list gnome org
- Subject: how to create bridge on main interface?
- Date: Tue, 23 Mar 2021 15:28:06 +0100
Hello.
Hopefully this is good place to ask. If not, please suggest something
else.
For quite some time I'm trying to figure out how to create a bridge
using main network interface (the only one which is routable to the host).
I have tried these Ansible tasks:
- name: "Get {{ public_nic }} connection name"
shell: nmcli --terse device | grep "^{{ public_nic }}:" | cut -d ':' -f 4
register: public_connection_cmd
- name: "Extract {{ public_nic }} connection name"
set_fact:
public_connection: "{{ public_connection_cmd.stdout_lines|first|trim }}"
- name: "Create brpublic bridge connection"
nmcli:
conn_name: brpublic
ifname: brpublic
type: bridge
stp: no
state: present
- name: "Put {{ public_nic }} device into brpublic"
nmcli:
conn_name: brpublic-slave
ifname: "{{ public_nic }}"
type: bridge-slave
master: brpublic
state: present
- name: "Remove old {{ public_nic }} connection"
nmcli:
conn_name: "{{ public_connection }}"
state: absent
when: "public_connection != '' and public_connection != 'brpublic-slave'"
but this breaks the network on the last task.
I have also tried these two ways via "shell":
set -xe
old_connection=$( nmcli --terse device | grep "^{{ public_nic }}:" | cut -d ':' -f 4 )
nmcli con add type bridge con-name brpublic ifname brpublic
###nmcli con add type bridge-slave con-name brpublic-slave ifname "{{ public_nic }}" master brpublic
nmcli connection modify "$old_connection" master brpublic
###if [ -n "$old_connection" -a "$old_connection" != 'brpublic-slave' ]; then
### nmcli c delete "$old_connection"
###fi
nmcli con up brpublic
but this fails as well (script works, but at the end according to `ip a` IP
is still on the main interface, not on "brpublic").
Mine end goal is to have VM on that bridge that can be accessible from
outside network.
What is the right way to do that remotely?
Thank you in advance,
Jan
--
Jan Hutar Performance Engineering
jhutar redhat com Red Hat, Inc.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]