今回は「Ubuntu 20.04 LTSで仮想サーバ用のbr0/ブリッジを追加しIPを固定する」です。
物理インタフェイスenp2s0は固定IPの設定です。
この設定の記事はこちら
このインターフェイスを共有できるように、内部ブリッジインターフェイスbr0を新設し固定IPを移します。
尚、記事中の設定はインデントが外れています。コピーの際はご注意ください。
■固定IPの設定
takumi@tubs01:~$ sudo cat /etc/netplan/99_config.yaml
network:
version: 2
renderer: networkd
ethernets:
enp2s0:
dhcp4: no
dhcp6: yes
addresses: [192.168.0.142/24]
gateway4: 192.168.0.1
nameservers:
addresses: [192.168.0.1]
■固定IPの確認
takumi@tubs01:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:1d:09:05:25:a3 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.142/24 brd 192.168.0.255 scope global enp2s0
valid_lft forever preferred_lft forever
inet6 2400:4051:641:8810:21d:9ff:fe05:25a3/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 14398sec preferred_lft 14398sec
inet6 fe80::21d:9ff:fe05:25a3/64 scope link
valid_lft forever preferred_lft forever
takumi@tubs01:~$ sudo cat /etc/netplan/99_config.yaml
network:
version: 2
renderer: networkd
ethernets:
enp2s0:
dhcp4: no
dhcp6: yes
addresses: [192.168.0.142/24]
gateway4: 192.168.0.1
nameservers:
addresses: [192.168.0.1]
■固定IPの確認
takumi@tubs01:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:1d:09:05:25:a3 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.142/24 brd 192.168.0.255 scope global enp2s0
valid_lft forever preferred_lft forever
inet6 2400:4051:641:8810:21d:9ff:fe05:25a3/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 14398sec preferred_lft 14398sec
inet6 fe80::21d:9ff:fe05:25a3/64 scope link
valid_lft forever preferred_lft forever
■br0ブリッジを新設し固定IPを移す
物理インターフェイスの持つ固定IPの設定を新設のbr0に移します。
takumi@tubs01:~$ sudo nano /etc/netplan/99_config.yaml
takumi@tubs01:~$ sudo cat /etc/netplan/99_config.yaml
network:
version: 2
renderer: networkd
ethernets:
enp2s0:
dhcp4: no
dhcp6: no
bridges:
br0:
interfaces: [enp2s0]
dhcp4: no
dhcp6: yes
addresses: [192.168.0.142/24]
gateway4: 192.168.0.1
nameservers:
addresses: [192.168.0.1]
■br0設定を反映し結果を確認する
takumi@tubs01:~$ sudo netplan apply
takumi@tubs01:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
link/ether 00:1d:09:05:25:a3 brd ff:ff:ff:ff:ff:ff
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:1d:09:05:25:a3 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.142/24 brd 192.168.0.255 scope global br0
valid_lft forever preferred_lft forever
inet6 2400:4051:641:8810:21d:9ff:fe05:25a3/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 14396sec preferred_lft 14396sec
inet6 fe80::21d:9ff:fe05:25a3/64 scope link
valid_lft forever preferred_lft forever
takumi@tubs01:~$
期待通りです。
物理インターフェイスの持つ固定IPの設定を新設のbr0に移します。
takumi@tubs01:~$ sudo nano /etc/netplan/99_config.yaml
takumi@tubs01:~$ sudo cat /etc/netplan/99_config.yaml
network:
version: 2
renderer: networkd
ethernets:
enp2s0:
dhcp4: no
dhcp6: no
bridges:
br0:
interfaces: [enp2s0]
dhcp4: no
dhcp6: yes
addresses: [192.168.0.142/24]
gateway4: 192.168.0.1
nameservers:
addresses: [192.168.0.1]
■br0設定を反映し結果を確認する
takumi@tubs01:~$ sudo netplan apply
takumi@tubs01:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
link/ether 00:1d:09:05:25:a3 brd ff:ff:ff:ff:ff:ff
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:1d:09:05:25:a3 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.142/24 brd 192.168.0.255 scope global br0
valid_lft forever preferred_lft forever
inet6 2400:4051:641:8810:21d:9ff:fe05:25a3/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 14396sec preferred_lft 14396sec
inet6 fe80::21d:9ff:fe05:25a3/64 scope link
valid_lft forever preferred_lft forever
takumi@tubs01:~$
期待通りです。
いつもアクセスありがとうございます。引き続きUbuntuでの気付きを投稿していきますので、よろしくおねがいします。