LoginSignup
12
15

More than 5 years have passed since last update.

CentOS 7 ネットワーク設定

Last updated at Posted at 2018-02-26

動作確認環境

  • 仮想環境 VMware Workstation Player 14.1.1
  • OS Windows 10 Pro 64bit

仮想環境

  • OS CentOS 7.4 (1708) minimalインストール
  • メモリ 2GB
  • HDD 250GB

ネットワーク設定

自動接続
OS起動時に自動的にネットワークに接続するため、コマンドを実行する。

nmcli con mod eth0 connection.autoconnect yes

IPアドレスをDHCP設定する場合

nmcli con mod eth0 ipv4.method auto

IPアドレスを手動設定する場合

  • IPアドレス 192.168.1.10
  • ゲートウェイ 192.168.1.1
  • DNS 8.8.8.8
nmcli con mod eth0 ipv4.method manual ipv4.addresses 192.168.1.10/24 ipv4.gateway 192.168.1.1 ipv4.dns 8.8.8.8

手動設定時には、DHCPでのDNSサーバの設定を無効にするため、コマンドを実行する。

nmcli con mod eth0 ipv4.ignore-auto-dns yes

NetworkManagerを再起動する。

systemctl restart NetworkManager

DNSサーバが設定されていることを、resolv.confファイルで確認する。

vi /etc/resolv.conf
/etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8

ホストの名前を変更する
以下のコマンドでホストの名前を変更する。

nmcli general hostname [ホスト名]

systemd-hostnamedを再起動して適用させる。

systemctl restart systemd-hostnamed

目次

12
15
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
12
15