Network manager - konfigurácia bridgu cez nmcli Fedora

Network manager - konfigurácia bridgu cez nmcli Fedora

nmcli je nástroj príkazového riadka na ovládanie NetworkManager a hlásenie stavu siete. nmcli sa používa na vytváranie, zobrazenie, úpravu, mazanie, aktiváciu a deaktiváciu sieťového pripojenia.

Všetko sa odohráva v adresári /etc/NetworkManager/system-connections

nmcli con show
NAME                  UUID                                  TYPE      DEVICE 
Drôtové pripojenie 1  cc8b0772-86b0-3c43-84eb-d3b5d98388dc  ethernet  enp2s0 
Drôtové pripojenie 2  cd7c8c63-d079-3a43-ac1a-c18b2b757a9d  ethernet  enp3s0    
sudo nmcli con add ifname virbr1 type bridge con-name virbr1
sudo nmcli con add type bridge-slave ifname enp3s0 master virbr1
sudo nmcli connection modify "virbr1" IPv4.address 192.168.2.253/24
sudo nmcli connection modify 'virbr1' IPv4.gateway 192.168.2.254
sudo nmcli connection modify 'virbr1' IPv4.dns 8.8.8.8
sudo nmcli connection modify 'virbr1' IPv4.method manual
sudo nmcli con down "Drôtové pripojenie 2"
sudo nmcli con up virbr1
nmcli con show
NAME                  UUID                                  TYPE      DEVICE 
Drôtové pripojenie 1  cc8b0772-86b0-3c43-84eb-d3b5d98388dc  ethernet  enp2s0 
virbr1                c9184d43-dfeb-4172-8219-75bbb82b5ae6  bridge    virbr1 
bridge-slave-enp3s0   d6162b7e-9b18-40fc-9891-d764c1f8b64e  ethernet  enp3s0 
Drôtové pripojenie 2  cd7c8c63-d079-3a43-ac1a-c18b2b757a9d  ethernet  --     
ls /etc/NetworkManager/system-connections
 bridge-slave-enp3s0.nmconnection  Drôtové pripojenie 1.nmconnection  Drôtové pripojenie 2.nmconnection   virbr1-c9184d43-dfeb-4172-8219-75bbb82b5ae6.nmconnection
ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp2s0:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 18:c0:4d:cc:9f:b4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.252/24 brd 192.168.2.255 scope global noprefixroute enp2s0
       valid_lft forever preferred_lft forever
    inet6 fe80::1f33:f47f:ed31:dbe4/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: enp3s0:  mtu 1500 qdisc fq_codel master virbr1 state UP group default qlen 1000
    link/ether 68:05:ca:63:ab:60 brd ff:ff:ff:ff:ff:ff
4: virbr1:  mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether be:63:a5:8a:95:24 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.253/24 brd 192.168.2.255 scope global noprefixroute virbr1
       valid_lft forever preferred_lft forever

Marek Mihók