본문 바로가기
IT 지식정리/운영체제

리눅스 DHCP 클라이언트 설정방법

by G. Hong 2018. 3. 25.
728x90
반응형

Step1. dhclient 패키지 설치

yum을 통해서 dhclient 패키지를 검색 및 설치를 합니다.

[root@centos test1]# yum search dhclient
Loaded plugins: fastestmirror, langpacks
...생략...
dhclient.x86_64 : Provides the ISC DHCP client daemon and dhclient-script

  Name and summary matches only, use "search all" for everything.
[root@centos test1]# yum install dhclient.x86_64


Step2. 네트워크 설정

/etc/sysconfig/network-scripts/ifcfg-<interface> 파일의 BOOTPROTO 항목과 etc/sysconfig/network 파일의 NETWORKING 항목을 설정하여 줍니다.

[root@centos test1]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE="Ethernet"
BOOTPROTO="dhcp"
NAME="enp0s3"
UUID="10f36a96-967b-413d-b771-298d437168be"
DEVICE="enp0s3"
ONBOOT="yes"
NM_CONTROLLER="no"
HWADDR="08:00:27:75:0e:d2"
GATEWAY="10.0.2.1"

[root@centos test1]# cat /etc/sysconfig/network
# Created by anaconda
NETWORKING=yes
HOSTNAME=centos.demo.lan
GATEWAY=10.0.0.1


Step3. ip주소 할당 요청

클라이언트가 네트워크에 연결이 되게 되면 dhcp서버로 ip주소 할당 요청을 하게 됩니다. 또는 dhclient 커맨드를 통해서 ip주소할당을 요청할 수 있습니다.

[root@centos test1]# dhclient 

[root@centos test1]# dhclient enp0s3


*그리고 /etc/dhclient.conf 파일을 통해서 커스텀 설정도 가능합니다.

[root@centos test1]# cat /etc/dhclient.conf
cat: /etc/dhclient.conf: No such file or directory //기본 설정을 사용하게 되면 파일이 존재하지 않습니다.


/var/lib/dhclient/dhclient.leases 파일에서 체결된 dhcp관련 정보들을 확인 할 수 있습니다.
[root@centos test1]# cat /var/lib/dhclient/dhclient.leases
lease {
  interface "enp0s3";
  fixed-address 10.0.2.15;
  filename "Centos.pxe";
  option subnet-mask 255.255.255.0;
  option dhcp-lease-time 86400;
  option routers 10.0.2.2;
  option dhcp-message-type 5;
  option dhcp-server-identifier 10.0.2.2;
  option domain-name-servers 168.126.63.1,168.126.63.2;
  renew 0 2018/03/04 17:16:40;
  rebind 1 2018/03/05 03:54:19;
  expire 1 2018/03/05 06:54:19;
}


728x90
반응형