0
0

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 1 year has passed since last update.

CentOS7のIPアドレス/デフォルトゲートウェイ/DNSサーバの再設定

Last updated at Posted at 2021-05-28

CentOS7のIPアドレス/デフォルトゲートウェイ/DNSサーバの再設定

環境

  • VMware Workstation 16 Player
  • CentOS7

デバイス確認

[root@localhost ~]# nmcli device
DEVICE       TYPE      STATE      CONNECTION
eth0         ethernet  connected  ens33
lo           loopback  unmanaged  --

設定変更(nmcli ~)

# 固定IPv4アドレス設定
[root@localhost ~]# nmcli connection modify ens33 ipv4.addresses 192.168.0.100

# デフォルトゲートウェイ設定
[root@localhost ~]# nmcli connection modify ens33 ipv4.gateway 192.168.0.1

# 参照する DNS設定
[root@localhost ~]# nmcli connection modify ens33 ipv4.dns 192.168.0.1

# インターフェースを再起動して設定を反映
[root@localhost ~]# nmcli connection down ens33; nmcli connection up ens33

設定後確認

# 設定確認
[root@localhost ~]# nmcli device show ens33
GENERAL.DEVICE:                 ens33
GENERAL.TYPE:                   ethernet
GENERAL.HWADDR:                 00:0C:29:CD:9C:2D
GENERAL.MTU:                    1500
GENERAL.STATE:                  100 (connected)
GENERAL.CONNECTION:             ens33
GENERAL.CON-PATH:               /org/freedesktop/NetworkManager/ActiveConnection/2
WIRED-PROPERTIES.CARRIER:       on
IP4.ADDRESS[1]:                 192.168.0.100/24
IP4.GATAWAY:                    192.168.0.1
IP4.ROUTE[1]:                   dst = 192.168.0.0/24, nh = 0.0.0.0, mt = 100
IP4.DNS[1]:                     192.168.0.1


# 接続確認
[root@localhost ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:cd:9c:2d brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.100/24 brd 192.168.0.255scope global ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fecd:9c2d/64 scope link
       valid_lft forever preferred_lft forever
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?