差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
linux:commands:network:network_manager_bridge [2021/11/29 14:25] – ともやん | 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 delete | + | <b class=GRN> |
- | $ sudo nmcli con delete | + | <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 color_term> |
- | <WRAP color_command>< | + | <WRAP color_command>< |
- | $ sudo nmcli con add type bridge ifname br0 | + | <b class=GRN>$</b> <b class=HIY>sudo</b> nmcli con add type bridge ifname |
- | </ | + | </pre></html></ |
- | <WRAP color_result><code> | + | < |
- | 接続 ' | + | 接続 ' |
- | </code></WRAP> | + | </pre></ |
- | <WRAP color_command>< | + | |
- | $ sudo nmcli con add type bridge ifname | + | |
- | </code></WRAP> | + | |
- | <WRAP color_result>< | + | |
- | 接続 ' | + | |
- | </code></ | + | |
- | < | + | |
- | $ sudo nmcli con add type bridge ifname br2 | + | |
- | </ | + | |
- | <WRAP color_result><code> | + | |
- | 接続 ' | + | |
- | </code></ | + | |
</ | </ | ||
追加された仮想ブリッジの確認。 | 追加された仮想ブリッジの確認。 | ||
- | < | + | <WRAP color_term> |
- | <WRAP color_command>< | + | <WRAP color_command>< |
- | $ nmcli con | + | <b class=GRN> |
- | </code></ | + | </pre></ |
- | <WRAP color_result>< | + | <WRAP color_result>< |
- | 名前 | + | NAME |
- | bridge-br2 b6b87482-2903-469f-a077-d62b1076ad27 | + | <b class=YEL> |
- | bridge-br1 | + | <b class=GRN> |
- | bridge-br0 3e2abe55-38c6-4ed6-8b75-178eb60850ca | + | <b class=CYN> |
- | eno1 b00bea8d-9069-4614-8870-614132313886 | + | TomoyanWRT-GL24G c2b00424-24bd-43ae-86af-af62bb7fd4e1 |
- | </code></ | + | </pre></ |
</ | </ | ||
デバイスを仮想ブリッジに接続する。(仮想ブリッジスレーブの追加)\\ | デバイスを仮想ブリッジに接続する。(仮想ブリッジスレーブの追加)\\ | ||
- | < | + | <WRAP color_term> |
- | <WRAP color_command>< | + | <WRAP color_command>< |
- | $ sudo nmcli con add type bridge-slave ifname enp3s0 master bridge-br0 | + | <b class=GRN>$</b> <b class=HIY>sudo</b> nmcli con add type bridge-slave ifname |
- | </ | + | </pre></html></ |
- | <WRAP color_result><code> | + | < |
- | 接続 ' | + | 接続 ' |
- | </code></WRAP> | + | </pre></ |
- | <WRAP color_command>< | + | |
- | $ sudo nmcli con add type bridge-slave ifname | + | |
- | </code></WRAP> | + | |
- | <WRAP color_result>< | + | |
- | 接続 ' | + | |
- | </code></ | + | |
- | < | + | |
- | $ sudo nmcli con add type bridge-slave ifname enp8s0f1 master bridge-br2 | + | |
- | </ | + | |
- | <WRAP color_result><code> | + | |
- | 接続 ' | + | |
- | </code></ | + | |
</ | </ | ||
追加された仮想ブリッジスレーブの確認。\\ | 追加された仮想ブリッジスレーブの確認。\\ | ||
- | ※この段階で br1、br2 は DHCP によりIPアドレスが振られて利用可能な状態となる。 | + | <WRAP color_term> |
- | < | + | <WRAP color_command>< |
- | <WRAP color_command>< | + | <b class=GRN> |
- | $ nmcli con | + | </pre></ |
- | </code></ | + | <WRAP color_result>< |
- | <WRAP color_result>< | + | NAME UUID |
- | 名前 | + | <b class=YEL> |
- | bridge-slave-enp8s0f1 | + | <b class=GRN> |
- | bridge-slave-enp8s0f0 | + | <b class=CYN> |
- | bridge-slave-enp3s0 | + | TomoyanWRT-GL24G |
- | bridge-br2 | + | bridge-slave-enp8s0 |
- | bridge-br1 | + | </pre></html></ |
- | bridge-br0 | + | |
- | eno1 | + | |
- | </code></WRAP> | + | |
- | <WRAP color_command>< | + | |
- | $ nmcli dev | + | |
- | </ | + | |
- | <WRAP color_result>< | + | |
- | デバイス | + | |
- | br0 | + | |
- | br1 | + | |
- | br2 | + | |
- | enp3s0 | + | |
- | enp8s0f0 | + | |
- | enp8s0f1 | + | |
- | lo loopback | + | |
- | </code></ | + | |
</ | </ | ||
仮想ブリッジの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 " | ||
行 185: | 行 143: | ||
ipv4.dns-search " | ipv4.dns-search " | ||
ipv4.never-default no | ipv4.never-default no | ||
- | $ sudo nmcli connection modify bridge-br1 \ | + | </pre></html></ |
- | bridge.stp no \ | + | |
- | ipv4.method manual ipv4.addresses " | + | |
- | ipv4.gateway " | + | |
- | ipv4.dns " | + | |
- | ipv4.dns-search " | + | |
- | ipv4.never-default yes | + | |
- | $ sudo nmcli connection modify bridge-br2 \ | + | |
- | bridge.stp no \ | + | |
- | ipv4.method manual ipv4.addresses " | + | |
- | ipv4.gateway " | + | |
- | ipv4.dns " | + | |
- | ipv4.dns-search " | + | |
- | ipv4.never-default yes | + | |
- | </code></ | + | |
</ | </ | ||
※ipv4.never-default no は DEFROUTE=yes となる。\\ | ※ipv4.never-default no は DEFROUTE=yes となる。\\ | ||
行 205: | 行 149: | ||
アクティブインタフェースの削除と再起動。\\ | アクティブインタフェースの削除と再起動。\\ | ||
※SSHによるリモート作業では、削除と共に再起動する必要がある。 | ※SSHによるリモート作業では、削除と共に再起動する必要がある。 | ||
- | < | + | <WRAP color_term> |
- | <WRAP color_command>< | + | <WRAP color_command>< |
- | $ sudo nmcli connection delete eno1; | + | <b class=GRN> |
- | </ | + | </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</ | ||
+ | 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 | ||
+ | </ | ||
</ | </ | ||
行 216: | 行 356: | ||
[[https:// | [[https:// | ||
- | ====== ブリッジ接続の設定(network編) | + | ==== 付録 ==== |
+ | [[tw> | ||
+ | |||
+ | ====== ☢️古い資料です (Obsolete)☢️ ====== | ||
+ | |||
+ | ===== ブリッジ接続の設定(network編) ===== | ||
- | ===== NetworkManager の無効化 | + | ==== 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 / | ||
行 263: | 行 408: | ||
</ | </ | ||
- | ===== NICのブリッジ設定 | + | ==== NICのブリッジ設定 ==== |
- | < | + | <WRAP color_term> |
- | <WRAP color_command>< | + | <WRAP color_command>< |
$ sudo vi / | $ sudo vi / | ||
- | </code></ | + | </pre></ |
</ | </ | ||