Deprecated: Return type of Requests_Cookie_Jar::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 63

Deprecated: Return type of Requests_Cookie_Jar::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 73

Deprecated: Return type of Requests_Cookie_Jar::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 89

Deprecated: Return type of Requests_Cookie_Jar::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 102

Deprecated: Return type of Requests_Cookie_Jar::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 111

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 40

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 51

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 68

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 82

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 91

Deprecated: Return type of AIOSEO\Plugin\Common\Models\Model::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 409

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174
CentOS7にDHCPサーバをインストールしルータのDHCPサーバを停止 | reyfox blog

reyfox blog

reyfox tech info

CentOS DHCP Linux ネットワーク

CentOS7にDHCPサーバをインストールしルータのDHCPサーバを停止

投稿日:

現在販売されている市販のルータにはDHCPサーバという家庭内LANのIPを自動で払い出してくれる機能がだいたい標準で装備されています。
ただ、製品によってはDHCPで払い出しているマシンに固定IPを割り振れないというものもあります。
そこで、Linux(CentOS7)にDHCPサーバをインストール設定し、固定IPで割り振りたいものは別途設定するという方法を取りたいと思います。

この方法では、ルータのDHCPサーバを停止する必要があり、切替時にネットワークに接続できなくなったり設定によってはLinuxマシン側での操作が必要になる場合があるので注意してください。

注意

このIPはサンプルですので、ネットワーク環境によって置き換えてください。
例: 192.168.xxx.1 → 192.168.1.1 等
このMACアドレスはダミーですので実際のMACアドレスを調べて指定してください。

DHCPサーバのインストールと設定

まずは yum でインストールから。


yum -y install dhcp

vi /etc/dhcp/dhcpd.conf でDHCPサーバの設定をします。


option domain-name     "reyfox.local";
option domain-name-servers     192.168.xxx.2;
default-lease-time 600;
max-lease-time 7200;
authoritative;
subnet 192.168.xxx.0 netmask 255.255.255.0 {
    range dynamic-bootp 192.168.xxx.50 192.168.xxx.254;
    option broadcast-address 192.168.xxx.255;
    option routers 192.168.xxx.1;
}

host nuc {
        hardware ethernet 00:00:00:00:00:01;
        fixed-address 192.168.xxx.2;
}
host esxi {
        hardware ethernet 00:00:00:00:00:02;
        fixed-address 192.168.xxx.3;
}

nuc(MACアドレス: 00:00:00:00:00:01)を192.168.xxx.2
esxi(MACアドレス: 00:00:00:00:00:02)を192.168.xxx.3
に固定で割り当てる設定を入れます。

MACアドレスは、Linuxマシンの場合は ip a で表示されます。
WindowsマシンやMacの場合はネットワークの設定から確認できます。
ESXiはWebConsoleからネットワーク→vmnic0→MACアドレス に表示されます。
ESXiのVMは仮想のMACアドレスが割り当てられています。
WebConsoleからネットワーク→VM Network→部分に表示されます。

説明

ドメイン名は reyfox.local とし、
割り振るDHCPのアドレスの範囲は、192.168.xxx.50〜192.168.xxx.254までとします。
192.168.xxx.1〜192.168.xxx.49までは固定IP用の予約としてとっておきます。
MACアドレスが一致したものに関しては、固定IPとして割り振ります。
DNSサーバは、このLinuxサーバ(192.168.xxx.2)とします。
ルータ(ゲートウェイ)は192.168.xxx.1 とします。
DNSサーバはまだありませんが内向き専用のDNSを立てる記事がありますので参考にしてください。

CentOS7で内向き専用DNSサーバを立てる

自動起動の設定と起動


systemctl start dhcpd 
systemctl enable dhcpd 

dhcpdの起動前に、ルータのDHCPサーバが停止しているのを確認してください。
ルータのDHCPサーバが起動したままだと誤動作の原因となります。

-CentOS, DHCP, Linux, ネットワーク

執筆者:

関連記事

grafana+prometheusでサーバ監視をしグラフィカルなダッシュボードを作る

少し前までは、fluentd+elasticsearch+kibanaというダッシュボードが流行っていた気がしますが、elasticsearchはJavaで動いているため非常に多くのメモリを消費すると …

CentOS7の初期設定

CentOS7 を Intel NUC にインストールしましたが今の所家庭内ネットワークからのみの想定で、外部からのアクセスはすべてルータでフィルタリングしているため、利便性のため下記の設定を行います …

CentOS7にMySQLサーバ(mariaDB)をインストールする

CentOS7からMySQLにかわりmariaDBが採用されていますが、使い方はほぼ MySQLと同じでいけます。 インストール いつもの通り、yumで。 yum install mariadb-se …

CentOS7でmuninでサーバを監視する

muninは非常に簡単でサーバの状態を確認できるツールとなっています。 インストールと設定 yum install munin-apache.noarch munin-node munin-commo …

CentOS7にPHP 7.2をインストール

WebプログラミングでおなじみPHPをインストール設定します。PHPは現在では最新が7.2となっていて、CentOS7標準のリポジトリで提供されている5.4は古いのでインストールしません。 インストー …


Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174