107
104

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.

CentOS7でIPを固定する

Last updated at Posted at 2014-07-09

IPを固定する

/etc/sysconfig/network-scripts/ifcfg-enp3s0
 DEVICE="enp3s0"
 ONBOOT=yes
 NETBOOT=yes
 UUID="0ebc2621-6086-4d9a-a15d-c52cdf6ade01"
 IPV6INIT=no
-BOOTPROTO=dhcp
 HWADDR="08:00:27:bf:e6:ec"
 TYPE=Ethernet
 NAME="enp3s0"

+BOOTPROTO=static
+DNS1="8.8.8.8"
+DNS2="8.8.4.4"
+DOMAIN=mydomain.com
+IPADDR=192.168.100.11
+NETMASK=255.255.255.0
+GATEWAY=192.168.100.1

IPを自動取得する場合

/etc/sysconfig/network-scripts/ifcfg-enp3s0
 DEVICE="enp3s0"
 ONBOOT=yes
 NETBOOT=yes
 UUID="0ebc2621-6086-4d9a-a15d-c52cdf6ade01"
 IPV6INIT=no
 BOOTPROTO=dhcp
 HWADDR="08:00:27:bf:e6:ec"
 TYPE=Ethernet
 NAME="enp3s0"
+DNS1="8.8.8.8"
+DNS2="8.8.4.4"

IPを固定しつつ自動取得もする

  • BOOTPROTO=dhcpがミソ
/etc/sysconfig/network-scripts/ifcfg-enp3s0
 DEVICE="enp3s0"
 ONBOOT=yes
 NETBOOT=yes
 UUID="0ebc2621-6086-4d9a-a15d-c52cdf6ade01"
 IPV6INIT=no
 BOOTPROTO=dhcp
 HWADDR="08:00:27:bf:e6:ec"
 TYPE=Ethernet
 NAME="enp3s0"

+DNS1="8.8.8.8"
+DNS2="8.8.4.4"
+DOMAIN=mydomain.com
+IPADDR=192.168.100.11
+NETMASK=255.255.255.0
+GATEWAY=192.168.100.1

/etc/sysconfig/network

NETWORKING="yes"
GATEWAYDEV="enp3s0"
NETWORKING_IPV6="no"
IPV6_DEFAULTDEV="enp3s0"
GATEWAY=192.168.100.1

/etc/hostname

dell.mydomain.com

設定反映

systemctl daemon-reload
systemctl restart network

IPv6を無効

/etc/sysctl.d/98-disableipv6.conf
net.ipv6.conf.all.disable_ipv6 = 1
/etc/sysconfig/network-scripts/ifcfg-enp3s0
- IPV6INIT=yes
+ IPV6INIT=no

reboot

確認
sysctl -a | grep disable_ipv6
107
104
2

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
107
104

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?