질문&답변
클라우드/리눅스에 관한 질문과 답변을 주고 받는 곳입니다.
리눅스 분류

DHCP 서버맹글어 인터넷 즐기기

작성자 정보

  • Gunman 작성
  • 작성일

컨텐츠 정보

본문

DHCP 서버맹글어 인터넷 즐기기
-------------------------------------------------
ID : Gunman
Email:kjw38317@yahoo.co.kr
2005/09/18
테스트 서버 OS: 리누기 (빨간모자 아저씨 9.0) kernel 2.4.20-8)
거 인용은 좋은데 이름은 바꾸지 말아주세요 ^^!
-------------------------------------------------

안녕하세요. ^^
그냥 간단하게 나름데로 정리 한것인데 새로 DHCP를 구성하고자 하는 분이 있으시면
조금도움이 될것 같아 이렇게 글을 올립니다.

구성계획
(외부인터넷)-(client 20개 연결)
전제조건 내부 client 20개가 인터넷을 공유 할수 있도록 한다.

eth0(외부인터넷측)
ech1(클라이언트측)

우선 제가 설정한 기준으로
eth0 - 외부측
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.150.20.2
GATEWAY=10.150.20.1
NETMASK=255.255.255.240

eth1 - 내부측
cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=static
IPADDR=10.25.10.1
NETMASK=255.255.255.0
ONBOOT=yes

#vi /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
# sysctl.conf(5) for more details.

# Controls IP packet forwarding
net.ipv4.ip_forward = 0 <--- 이부분을 1로 바꾸 주세요.

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1

이렇게 해주신다음
#cat /proc/sys/net/ipv4/ip_forward 으로확인 하여주시고 만약 0으로 되어있다면 재 확인 바랍니다.
1

다음에는
#vi /etc/sysconfig/network
NETWORKING=yes
GATEWAYDEV=eth0
FORWARD_IPV4=yes

다음은 iptables masquerade 시작
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 만약이렇게 하셨을떄 오류가

EX) /lib/modules/2.4.20-8smp/kernel/net/ipv4/netfilter/ip_tables.o: init_module: Device or resource busy
Hint: insmod errors can be caused by incorrect module parameters, including invalid IO or IRQ parameters.
      You may find more information in syslog or the output from dmesg
/lib/modules/2.4.20-8smp/kernel/net/ipv4/netfilter/ip_tables.o: insmod /lib/modules/2.4.20-

8smp/kernel/net/ipv4/netfilter/ip_tables.o failed
/lib/modules/2.4.20-8smp/kernel/net/ipv4/netfilter/ip_tables.o: insmod ip_tables failed
iptables v1.2.7a: can't initialize iptables table `nat': iptables who? (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.

위와 같이 나온다면 reboot 해주시면 됩니다. (물론 제경험상). ^^!
reboot후
iptables -L -t nat

차후 /etc/rc.d/rc.local 파일에 넣어두시면 편하시겠죠! --> iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

그다음
/etc/init.d/iptables save
현 규칙들을 /etc/sysconfig/iptables:로 저장하고 있습니다: [ 확인 ]
cat /etc/sysconfig/iptables
# Generated by iptables-save v1.2.7a on Sat Sep 17 22:58:17 2005
*nat
:PREROUTING ACCEPT [5674:399823]
:POSTROUTING ACCEPT [2:404]
:OUTPUT ACCEPT [3:475]
[4468:250424] -A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
# Completed on Sat Sep 17 22:58:17 2005

--DHCP 구성--
# route add -host 255.255.255.255 dev eth1
ftp://ftp.isc.org/ --> isc --> dhcp 에서 최신버전을 받으신다음
적당한 곳에 압축을 풀어 놓으시고
#./configure
# make && make install
# cp /usr/local/dhcpd/server/dhcpd.conf /etc/dhcpd.conf
# vi /etc/dhcpd.conf
#cat /etc/dhcpd.conf
 ddns-update-style ad-hoc; <-- 이것을 안넣어 줬더니 오류가 나더군요.
 default-lease-time 600; # 기본 임대 시간
 max-lease-time 7200; # 최대 임대 시간
 option subnet-mask 255.255.255.0;
 option broadcast-address 10.25.10.255;
 option routers 10.25.10.1;
 option domain-name-servers 194.84.23.125;
 server-name "HSDHCPS"; <--server의 Hostname 을 넣어 줬습니다.
 subnet 10.25.10.0 netmask 255.255.255.0 {
range 10.25.10.2 10.25.10.20; <--적용할 IP 수량
 }
subnet 10.150.20.0 netmask 255.255.255.240 { <---외부측 eth0
}

위와 같이 설정한다음
#touch /var/state/dhcp/dhcpd.leases

해서 DHCP 현황을 파악할수 있는 파일을 생성 시켜 주신다음
#/usr/sbin/dhcpd
해주시면 성공 ^^/

#tail -f /var/state/dhcp/dhcpd.leases
  uid "010000360q254254";
}
lease 10.25.10.128 {
  starts 6 2005/09/17 12:07:49;
  ends 6 2005/09/17 12:17:49;
  binding state active;
  next binding state free;
  hardware ethernet 00:00:f0:71:ac:ac;
  uid "010000360q254254";
}

혹시 부족한점이나 개선 할점이  있으시면 고수분들의 조언도 부탁드리겠습니다.

관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,138 명
  • 현재 강좌수 :  36,196 개
  • 현재 접속자 :  601 명