6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CoreOSの固定IPアドレス設定

Posted at

CoreOSで固定IPアドレスを設定する方法には二つある。
 1.cloud-confgで設定
 2./etc/systemd/network下に設定ファイルを置く

ここでは2の方法を示す。

/etc/systemd/network下にstatic.networkというファイルを置くことでIPアドレスの設定を行う。
とはいえ、いきなりstatic.networkを編集するのではなく、まずネットワークインタフェース名をifconfigで確認することから始める。

以下は実行例

$ ifconfig
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.42.1  netmask 255.255.0.0  broadcast 0.0.0.0
        inet6 fe80::42:fbff:fea9:2f7f  prefixlen 64  scopeid 0x20<link>
        ether 02:42:fb:a9:2f:7f  txqueuelen 0  (Ethernet)
        RX packets 181357  bytes 139012109 (132.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 188634  bytes 21561698 (20.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.211  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::20c:29ff:fea8:30d  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:a8:03:0d  txqueuelen 1000  (Ethernet)
        RX packets 16395876  bytes 1498915601 (1.3 GiB)
        RX errors 1  dropped 1397005  overruns 0  frame 0
        TX packets 286603  bytes 149610630 (142.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 19  base 0x2000

ens33がターゲット。
では改めて/etc/systemd/network/static.networkを作成。

[Match]
Name=ens33

[Network]
Address=192.168.1.5/24
Gateway=192.168.1.250
DNS=192.168.1.1

ここまで終わったら、再起動してもよいし、以下のコマンドを叩いてもよい。

sudo systemctl restart systemd-networkd

以上

6
7
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
6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?