본문 바로가기

Linux/Commands Part

DHCP

  1. 시스템 환경구성
  1. Vmware 머신 두개이상(여기서는 두대로 한다.)
  1. VMWare network 구성
    1. VMNet8 : NAT - dhcp활성화
    1. VMNet2 : host-only -dhcp비활성화 (subnet 10.10.10.0/24)
  1. 가상머신 구성
    1. 마스커레이드를 사용할 시스템
      1. NAT - dhcp ip 가져온다.
      2. VMnet2 : 10.10.10.10/24 (게이트웨이 설정 안함)

 

  1. DHCP : Dynamic Host Configuration Protocol

1) rpm -qa | grep dhcp 

2) yum install -y dhcp

3)vi /etc/dhcpd.conf

4)vi에서

:r /usr/share/doc/dhcp*/dhcpd.conf.sample

ddns-update-style interim;

ignore client-updates;

 

subnet 10.10.10.0 netmask 255.255.255.0 {

 

# --- default gateway

        option routers                  10.10.10.10;

        option subnet-mask              255.255.255.0;

 

#       option nis-domain               "domain.org";

        option domain-name              "itwithgod.lux";

#       option domain-name-servers      192.168.1.1;

#       option time-offset              -18000; # Eastern Standard Time

#       option ntp-servers              192.168.1.1;

#       option netbios-name-servers     192.168.1.1;

# --- Selects point-to-point node (default is hybrid). Don't change this unless

# -- you understand Netbios very well

#       option netbios-node-type 2;

 

        range dynamic-bootp 10.10.10.100 10.10.10.254;

        default-lease-time 21600;

        max-lease-time 43200;

 

        # we want the nameserver to appear at a fixed address

#       host ns {

#               next-server marvin.redhat.com;

#               hardware ethernet 12:34:56:78:AB:CD;

#               fixed-address 207.175.42.254;

#       }

}

#

=========================================================

세부설명

=========================================================

ddns-update-style interim;
동적 업데이트(Dynamic Update, Dynmic DNS) 기능을 사용할 수 있도록 지정하는 기능이다. 동적 업데이트 기능
을 사용하지 않는다면 "ddns-update-style none;" 지정하면 된다.
ignore client-updates;
subnet 10.10.10.0 netmask 255.255.255.0 {
정보를 제공하는 네트워크 범위 지정:10.10.10.0/255.255.255.0
# --- default gateway
option routers 192.168.0.1; /* Default Router IP */
option subnet-mask 255.255.255.0; /* Subnet Mask */
option nis-domain "domain.org"; /* NIS Domain Name */
option domain-name "domain.org"; /* DNS Domain Name */
DNS 서버는 필요하다면 여러대를 지정할 수도 있다.
options domain-name ns1.example.com ns2.example.com
option domain-name-servers 192.168.1.1; /* DNS Server IP */
option time-offset -18000; # Eastern Standard Time
"미국/동부" 타임 오프셋 (GMT - 5시간, -18000초 = -300분 = -5시간)
"아시아/서울" 타임 오프셋 (GMT + 9시간, 9시간 = 540분 = 32400초)
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 192.168.0.128 192.168.0.254; /* DHCP 서버 IP보유 영역 */
default-lease-time 21600; /* 21600초 = 360분 = 6시간 */
max-lease-time 43200; /* 43200초 = 720분 = 12시간 */
# we want the nameserver to appear at a fixed address
고정 IP 할당 지정
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 10.10.10.199;
}
host linux140 {
hardware ethernet 00:0C:29:EC:17:09;
fixed-address 10.10.10.200;
}
}

3. DHCP 아이피 임대로그파일 지켜보기

# tail -f /var/lib/dhcpd/dhcpd.leases

 

4. 방화벽 설정 (udp /67, 68)

vi /etc/sysconfig/iptables

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 67:68 -j ACCEPT

 

5. DHCP 데몬 재시작

# service dhcpd restart

 

6. 클라이언트 설정

1)    cat /etc/sysconfig/network-scripts/ifcfg-eth0 아래와 같이 되어 있으면 된다.

HWADDR 값은 시스템 마다 고유하므로 아래와 같이 않을 것이다.

# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]

DEVICE=eth0

BOOTPROTO=dhcp

ONBOOT=yes

HWADDR=00:0c:29:49:c0:c7

2)service network restart