差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
| linux:commands:network:network_manager_bridge [2021/11/29 14:49] – [仮想ブリッジインタフェースの追加] ともやん | linux:commands:network:network_manager_bridge [2024/02/04 03:05] (現在) – [トラブルシューティング] ともやん | ||
|---|---|---|---|
| 行 2: | 行 2: | ||
| ===== デバイスの確認 ===== | ===== デバイスの確認 ===== | ||
| - | <WRAP prewrap 100%> | ||
| sysfs でデバイス名を確認する場合。 | sysfs でデバイス名を確認する場合。 | ||
| <WRAP color_term> | <WRAP color_term> | ||
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| - | $ ls / | + | <b class=GRN> |
| - | </code></ | + | </pre></ |
| <WRAP color_result>< | <WRAP color_result>< | ||
| <b class=HIC> | <b class=HIC> | ||
| 行 15: | 行 14: | ||
| nmcli でデバイスを確認する場合。 | nmcli でデバイスを確認する場合。 | ||
| <WRAP color_term> | <WRAP color_term> | ||
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| - | $ nmcli dev | + | <b class=GRN> |
| - | </code></ | + | </pre></ |
| <WRAP color_result>< | <WRAP color_result>< | ||
| DEVICE | DEVICE | ||
| 行 29: | 行 28: | ||
| もしも、すべてのインタフェースが接続済みな場合は以下のような表示になる。 | もしも、すべてのインタフェースが接続済みな場合は以下のような表示になる。 | ||
| <WRAP color_term> | <WRAP color_term> | ||
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| - | $ nmcli dev | + | <b class=GRN> |
| - | </code></ | + | </pre></ |
| <WRAP color_result>< | <WRAP color_result>< | ||
| デバイス | デバイス | ||
| 行 42: | 行 41: | ||
| <WRAP color_term> | <WRAP color_term> | ||
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| - | $ nmcli con | + | <b class=GRN> |
| - | </code></ | + | </pre></ |
| <WRAP color_result>< | <WRAP color_result>< | ||
| 名前 | 名前 | ||
| 行 55: | 行 54: | ||
| その場合は、現在 SSH 接続しているインタフェースを残して、それ以外を削除しても問題ない。 | その場合は、現在 SSH 接続しているインタフェースを残して、それ以外を削除しても問題ない。 | ||
| <WRAP color_term> | <WRAP color_term> | ||
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| - | $ sudo nmcli con del enp8s0f0 | + | <b class=GRN> |
| - | $ sudo nmcli con del enp8s0f1 | + | <b class=GRN> |
| - | </code></ | + | </pre></ |
| </ | </ | ||
| 削除後の確認。 | 削除後の確認。 | ||
| <WRAP color_term> | <WRAP color_term> | ||
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| - | $ nmcli con | + | <b class=GRN> |
| - | </code></ | + | </pre></ |
| <WRAP color_result>< | <WRAP color_result>< | ||
| 名前 | 名前 | ||
| 行 73: | 行 72: | ||
| <WRAP color_term> | <WRAP color_term> | ||
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| - | $ nmcli dev | + | <b class=GRN> |
| - | </code></ | + | </pre></ |
| <WRAP color_result>< | <WRAP color_result>< | ||
| デバイス | デバイス | ||
| 行 82: | 行 81: | ||
| enp8s0f1 | enp8s0f1 | ||
| </ | </ | ||
| - | </ | ||
| </ | </ | ||
| ===== 仮想ブリッジインタフェースの追加 ===== | ===== 仮想ブリッジインタフェースの追加 ===== | ||
| - | <WRAP prewrap 100%> | ||
| 仮想ブリッジをデバイス数だけ追加する。 | 仮想ブリッジをデバイス数だけ追加する。 | ||
| <WRAP color_term> | <WRAP color_term> | ||
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| - | $ sudo nmcli con add type bridge ifname br0 | + | <b class=GRN> |
| - | </code></ | + | </pre></ |
| - | <WRAP color_result>< | + | <WRAP color_result>< |
| 接続 ' | 接続 ' | ||
| - | </code></ | + | </pre></ |
| </ | </ | ||
| 追加された仮想ブリッジの確認。 | 追加された仮想ブリッジの確認。 | ||
| - | < | + | <WRAP color_term> |
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| - | $ nmcli con | + | <b class=GRN> |
| - | </code></ | + | </pre></ |
| <WRAP color_result>< | <WRAP color_result>< | ||
| NAME UUID TYPE DEVICE | NAME UUID TYPE DEVICE | ||
| 行 112: | 行 109: | ||
| デバイスを仮想ブリッジに接続する。(仮想ブリッジスレーブの追加)\\ | デバイスを仮想ブリッジに接続する。(仮想ブリッジスレーブの追加)\\ | ||
| - | < | + | <WRAP color_term> |
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| - | $ sudo nmcli con add type bridge-slave ifname enp8s0 master bridge-br0 | + | <b class=GRN> |
| - | </code></ | + | </pre></ |
| - | <WRAP color_result>< | + | <WRAP color_result>< |
| 接続 ' | 接続 ' | ||
| - | </code></ | + | </pre></ |
| </ | </ | ||
| 追加された仮想ブリッジスレーブの確認。\\ | 追加された仮想ブリッジスレーブの確認。\\ | ||
| <WRAP color_term> | <WRAP color_term> | ||
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| - | $ nmcli con | + | <b class=GRN> |
| - | </code></ | + | </pre></ |
| <WRAP color_result>< | <WRAP color_result>< | ||
| NAME | NAME | ||
| 行 137: | 行 134: | ||
| 仮想ブリッジのIPアドレスを設定する。 | 仮想ブリッジのIPアドレスを設定する。 | ||
| - | < | + | <WRAP color_term> |
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| - | $ sudo nmcli connection modify bridge-br0 \ | + | <b class=GRN> |
| bridge.stp no \ | bridge.stp no \ | ||
| ipv4.method manual ipv4.addresses " | ipv4.method manual ipv4.addresses " | ||
| 行 146: | 行 143: | ||
| ipv4.dns-search " | ipv4.dns-search " | ||
| ipv4.never-default no | ipv4.never-default no | ||
| - | </code></ | + | </pre></ |
| </ | </ | ||
| ※ipv4.never-default no は DEFROUTE=yes となる。\\ | ※ipv4.never-default no は DEFROUTE=yes となる。\\ | ||
| 行 152: | 行 149: | ||
| アクティブインタフェースの削除と再起動。\\ | アクティブインタフェースの削除と再起動。\\ | ||
| ※SSHによるリモート作業では、削除と共に再起動する必要がある。 | ※SSHによるリモート作業では、削除と共に再起動する必要がある。 | ||
| - | < | + | <WRAP color_term> |
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| - | $ sudo nmcli connection delete eno1; | + | <b class=GRN> |
| - | </code></ | + | </pre></ |
| </ | </ | ||
| + | |||
| + | ===== トラブルシューティング ===== | ||
| + | Fedora 39 で KVM ゲストから Bridge (br0 など) で外部に通信できない場合😥\\ | ||
| + | [[https:// | ||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | <b class=DiYE> | ||
| + | net.bridge.bridge-nf-call-ip6tables = 1 | ||
| + | net.bridge.bridge-nf-call-iptables = 1</b> | ||
| + | net.bridge.bridge-nf-filter-pppoe-tagged = 0 | ||
| + | net.bridge.bridge-nf-filter-vlan-tagged = 0 | ||
| + | net.bridge.bridge-nf-pass-vlan-input-dev = 0 | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | iptables を設定して、全てのトラフィックがブリッジを渡って転送されるようにします🤔\\ | ||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | success | ||
| + | </ | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | success | ||
| + | </ | ||
| + | </ | ||
| + | <WRAP round tip 90%> | ||
| + | ルールを削除する場合\\ | ||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | 設定結果の確認🤔\\ | ||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | & | ||
| + | <b class=DiYE>& | ||
| + | & | ||
| + | & | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result_long>< | ||
| + | # Generated by iptables-save v1.8.9 (nf_tables) on Sun Feb 4 02:07:04 2024 | ||
| + | *mangle | ||
| + | :PREROUTING ACCEPT [0:0] | ||
| + | :INPUT ACCEPT [0:0] | ||
| + | :FORWARD ACCEPT [0:0] | ||
| + | :OUTPUT ACCEPT [0:0] | ||
| + | : | ||
| + | : | ||
| + | -A POSTROUTING -j LIBVIRT_PRT | ||
| + | -A LIBVIRT_PRT -o virbr0 -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill | ||
| + | COMMIT | ||
| + | # Completed on Sun Feb 4 02:07:04 2024 | ||
| + | # Generated by iptables-save v1.8.9 (nf_tables) on Sun Feb 4 02:07:04 2024 | ||
| + | *filter | ||
| + | :INPUT ACCEPT [0:0] | ||
| + | :FORWARD DROP [0:0] | ||
| + | :OUTPUT ACCEPT [0:0] | ||
| + | :DOCKER - [0:0] | ||
| + | : | ||
| + | : | ||
| + | : | ||
| + | : | ||
| + | : | ||
| + | : | ||
| + | : | ||
| + | : | ||
| + | -A INPUT -j LIBVIRT_INP | ||
| + | -A FORWARD -j DOCKER-ISOLATION-STAGE-1 | ||
| + | -A FORWARD -j DOCKER-USER | ||
| + | -A FORWARD -o docker0 -m conntrack --ctstate RELATED, | ||
| + | -A FORWARD -o docker0 -j DOCKER | ||
| + | -A FORWARD -i docker0 ! -o docker0 -j ACCEPT | ||
| + | -A FORWARD -i docker0 -o docker0 -j ACCEPT | ||
| + | -A FORWARD -j LIBVIRT_FWX | ||
| + | -A FORWARD -j LIBVIRT_FWI | ||
| + | -A FORWARD -j LIBVIRT_FWO | ||
| + | <b class=DiYE> | ||
| + | -A OUTPUT -j LIBVIRT_OUT | ||
| + | -A DOCKER-ISOLATION-STAGE-1 -j RETURN | ||
| + | -A DOCKER-ISOLATION-STAGE-2 -j RETURN | ||
| + | -A DOCKER-USER -j RETURN | ||
| + | -A LIBVIRT_FWI -d 192.168.122.0/ | ||
| + | -A LIBVIRT_FWI -o virbr0 -j REJECT --reject-with icmp-port-unreachable | ||
| + | -A LIBVIRT_FWO -s 192.168.122.0/ | ||
| + | -A LIBVIRT_FWO -i virbr0 -j REJECT --reject-with icmp-port-unreachable | ||
| + | -A LIBVIRT_FWX -i virbr0 -o virbr0 -j ACCEPT | ||
| + | -A LIBVIRT_INP -i virbr0 -p udp -m udp --dport 53 -j ACCEPT | ||
| + | -A LIBVIRT_INP -i virbr0 -p tcp -m tcp --dport 53 -j ACCEPT | ||
| + | -A LIBVIRT_INP -i virbr0 -p udp -m udp --dport 67 -j ACCEPT | ||
| + | -A LIBVIRT_INP -i virbr0 -p tcp -m tcp --dport 67 -j ACCEPT | ||
| + | -A LIBVIRT_OUT -o virbr0 -p udp -m udp --dport 53 -j ACCEPT | ||
| + | -A LIBVIRT_OUT -o virbr0 -p tcp -m tcp --dport 53 -j ACCEPT | ||
| + | -A LIBVIRT_OUT -o virbr0 -p udp -m udp --dport 68 -j ACCEPT | ||
| + | -A LIBVIRT_OUT -o virbr0 -p tcp -m tcp --dport 68 -j ACCEPT | ||
| + | COMMIT | ||
| + | # Completed on Sun Feb 4 02:07:04 2024 | ||
| + | # Generated by iptables-save v1.8.9 (nf_tables) on Sun Feb 4 02:07:04 2024 | ||
| + | *nat | ||
| + | :PREROUTING ACCEPT [0:0] | ||
| + | :INPUT ACCEPT [0:0] | ||
| + | :OUTPUT ACCEPT [0:0] | ||
| + | : | ||
| + | :DOCKER - [0:0] | ||
| + | : | ||
| + | -A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER | ||
| + | -A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER | ||
| + | -A POSTROUTING -s 172.17.0.0/ | ||
| + | -A POSTROUTING -j LIBVIRT_PRT | ||
| + | -A DOCKER -i docker0 -j RETURN | ||
| + | -A LIBVIRT_PRT -s 192.168.122.0/ | ||
| + | -A LIBVIRT_PRT -s 192.168.122.0/ | ||
| + | -A LIBVIRT_PRT -s 192.168.122.0/ | ||
| + | -A LIBVIRT_PRT -s 192.168.122.0/ | ||
| + | -A LIBVIRT_PRT -s 192.168.122.0/ | ||
| + | COMMIT | ||
| + | # Completed on Sun Feb 4 02:07:04 2024 | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ゲストで疎通確認😎\\ | ||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | $ ping google.com | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | PING google.com (142.251.222.46) 56(84) バイトのデータ | ||
| + | 64 バイト応答 送信元 nrt13s72-in-f14.1e100.net (142.251.222.46): | ||
| + | 64 バイト応答 送信元 nrt13s72-in-f14.1e100.net (142.251.222.46): | ||
| + | 64 バイト応答 送信元 nrt13s72-in-f14.1e100.net (142.251.222.46): | ||
| + | 64 バイト応答 送信元 nrt13s72-in-f14.1e100.net (142.251.222.46): | ||
| + | ^C | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ちなみに、< | ||
| + | なので Fedora 39 ではブリッジの転送許可を firewall-cmd で設定するしかない😉\\ | ||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | # sysctl settings are defined through files in | ||
| + | # / | ||
| + | # | ||
| + | # Vendors settings live in / | ||
| + | # To override a whole file, create a new file with the same in | ||
| + | # / | ||
| + | # only specific settings, add a file with a lexically later | ||
| + | # name in / | ||
| + | # | ||
| + | # For more information, | ||
| + | net.bridge.bridge-nf-call-ip6tables = 0 | ||
| + | net.bridge.bridge-nf-call-iptables = 0 | ||
| + | net.bridge.bridge-nf-call-arptables = 0 | ||
| + | </ | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | 合計 4 | ||
| + | lrwxrwxrwx. 1 root root 14 1月 22 09:00 <font color="# | ||
| + | </ | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | net.bridge.bridge-nf-call-arptables = 1 | ||
| + | net.bridge.bridge-nf-call-ip6tables = 1 | ||
| + | net.bridge.bridge-nf-call-iptables = 1 | ||
| + | net.bridge.bridge-nf-filter-pppoe-tagged = 0 | ||
| + | net.bridge.bridge-nf-filter-vlan-tagged = 0 | ||
| + | net.bridge.bridge-nf-pass-vlan-input-dev = 0 | ||
| + | </ | ||
| </ | </ | ||
| 行 164: | 行 356: | ||
| [[https:// | [[https:// | ||
| - | ====== ブリッジ接続の設定(network編) ====== | + | ==== 付録 |
| + | [[tw> | ||
| - | ===== NetworkManager の無効化 | + | ====== ☢️古い資料です (Obsolete)☢️ ====== |
| + | |||
| + | ===== ブリッジ接続の設定(network編) ===== | ||
| + | |||
| + | ==== NetworkManager の無効化 ==== | ||
| NetworkManager 0.9.8 より前はブリッジをサポートしないため、ネットワークスクリプトで構成する必要がある。\\ | NetworkManager 0.9.8 より前はブリッジをサポートしないため、ネットワークスクリプトで構成する必要がある。\\ | ||
| CentOS の場合 | CentOS の場合 | ||
| - | < | + | <WRAP color_term> |
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| $ sudo chkconfig NetworkManager off | $ sudo chkconfig NetworkManager off | ||
| $ sudo service NetworkManager stop | $ sudo service NetworkManager stop | ||
| - | </code></ | + | </pre></ |
| </ | </ | ||
| Fedora の場合 | Fedora の場合 | ||
| - | < | + | <WRAP color_term> |
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| $ sudo systemctl disable NetworkManager.service | $ sudo systemctl disable NetworkManager.service | ||
| $ sudo systemctl stop NetworkManager.service | $ sudo systemctl stop NetworkManager.service | ||
| $ sudo systemctl enable network.service | $ sudo systemctl enable network.service | ||
| $ sudo systemctl start network.service | $ sudo systemctl start network.service | ||
| - | </code></ | + | </pre></ |
| </ | </ | ||
| ※Fedora19 の NetworkManager は 0.9.8 からブリッジをサポートします。\\ | ※Fedora19 の NetworkManager は 0.9.8 からブリッジをサポートします。\\ | ||
| - | ===== ネットワークデバイス名の固定 | + | ==== ネットワークデバイス名の固定 ==== |
| Kernelアップデートでデバイス名が変わりインタフェースが使えなくなる場合は、以下の方法でデバイス名を固定する。\\ | Kernelアップデートでデバイス名が変わりインタフェースが使えなくなる場合は、以下の方法でデバイス名を固定する。\\ | ||
| [[linux: | [[linux: | ||
| - | ===== ブリッジ用インタフェースの設定 | + | ==== ブリッジ用インタフェースの設定 ==== |
| - | < | + | <WRAP color_term> |
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| $ sudo vi / | $ sudo vi / | ||
| - | </code></ | + | </pre></ |
| </ | </ | ||
| <code bash / | <code bash / | ||
| 行 211: | 行 408: | ||
| </ | </ | ||
| - | ===== NICのブリッジ設定 | + | ==== NICのブリッジ設定 ==== |
| - | < | + | <WRAP color_term> |
| - | <WRAP color_command>< | + | <WRAP color_command>< |
| $ sudo vi / | $ sudo vi / | ||
| - | </code></ | + | </pre></ |
| </ | </ | ||