LoginSignup
23
31

More than 5 years have passed since last update.

5行で出来るブリッジネットワークの作り方 in CentOS7.X

Posted at

ブリッジ接続便利ですよね、かなり使ってます。
DockerとかKVMとか利用用途が広いので覚えておくと便利です。
この作り方ならNetworkManagerを止めなくてもOK

ブリッジネットワークの作り方

1行目

# nmcli connection add type bridge con-name br0 ifname br0 stp no

ブリッジ「br0」を作成します。作成の際にSTPは止めておきます。

2行目

# nmcli connection modify br0 ipv4.method manual ipv4.addresses "192.168.0.1/24" ipv4.gateway "192.168.0.254" ipv4.dns 8.8.8.8

今回のキモですipv4.addressesにはブリッジ先のIPを割り当て、ipv4.gatewayにはそのGatewayを、ipv4.dnsには言わずもがなDNSを割り当てます。

3行目

# nmcli connection add type bridge ifname eth0 master br0

このコマンドでeth0とbr0をブリッジ接続しています。

4行目

# nmcli con del eth0

不要になったeth0を削除します。

5行目

# systemctl restart network

ネットワークを再起動して完成です。

昔みたく/etc/sysconfig/network-script/ifcfg-ethXを弄くったりしなくて良くて楽ちんですね!

まとめ(コピペ用)

nmcli connection add type bridge con-name br0 ifname br0 stp no
nmcli connection modify br0 ipv4.method manual ipv4.addresses "IPAddr/24" ipv4.gateway "Gateway" ipv4.dns 8.8.8.8
nmcli connection add type bridge ifname eth0 master br0
nmcli con del eth0
systemctl restart network
23
31
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
31