IP確認
# ip addr show 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: ens160: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 00:0c:29:43:31:48 brd ff:ff:ff:ff:ff:ff 3: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:43:31:3e brd ff:ff:ff:ff:ff:ff inet 192.168.0.177/24 brd 192.168.0.255 scope global ens33 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe43:313e/64 scope link valid_lft forever preferred_lft foreve r
ネットワーク(NIC)の確認
# lshw -short -class network H/W path Device Class Description ====================================================== /0/100/11/1 ens33 network 82545EM Gigabit Ethernet Controller ( /0/100/15/0 ens160 network VMXNET3 Ethernet Controller
変更前
元のNIC
NIC ens33: IP 192.168.0.177/24 G/W 210.160.237.178/29
変更後 元のNIC
NIC ens33: IP 192.168.0.177/24 経路 10.0.0.0/8 経路G/W 192.168.0.197
追加のNIC
NIC ens160 IP 210.160.237.178/29 default GW 210.160.237.182
設定ファイル
network: ethernets: ens33: addresses: - 192.168.0.177/24 routes: ←追加 - to: 10.0.0.0/8 ←追加 via: 192.168.0.197 ←追加 nameservers: addresses: - 192.168.0.243 search: - ootsuji-c.com ens160: ←追加 addresses: ←追加 - 210.160.237.178/29 ←追加 gateway4: 210.160.237.182 ←変更 version: 2
以下注意
インデントを間違うとSyntaxエラーになる インデントはスペースがよさそう
設定の有効化
# netplan apply
確認
$ ip addr show 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: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:43:31:48 brd ff:ff:ff:ff:ff:ff inet 210.160.237.178/29 brd 210.160.237.183 scope global ens160 ^^^^^^^^^^^^^^^^^^^^^^^^ valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe43:3148/64 scope link valid_lft forever preferred_lft forever 3: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:43:31:3e brd ff:ff:ff:ff:ff:ff inet 192.168.0.177/24 brd 192.168.0.255 scope global ens33 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe43:313e/64 scope link valid_lft forever preferred_lft forever