/l3/users/2014-11-nt-voip/nt-voip/root :1 :2 :3 :4 :5 :6 :7 :8 :9 :10 :11 :12 :13 :14 :15 :16 |
|
## установка и настройка dhcp
|
#apt-cache search dhcp server
ahcpd - Ad-Hoc Configuration Protocol avahi-autoipd - Avahi IPv4LL network address configuration daemon bootp - server for the bootp protocol with DHCP support udhcpd - Provides the busybox DHCP server implementation dhcp-helper - A DHCP relay agent dhcp-probe - network DHCP or BootP server discover dhcpdump - Parse DHCP packets from tcpdump dhcping - DHCP Daemon Ping Program dhis-server - Dynamic Host Information System - server dibbler-client - portable DHCPv6 client ... ltsp-server-standalone - complete LTSP server environment nagios-plugins-basic - Plugins for nagios compatible monitoring systems netdiscover - active/passive network address scanner using arp requests netdiscover-dbg - active/passive network address scanner using arp requests (debug) pump - BOOTP and DHCP client for automatic IP configuration pxe - free PXE daemon python-pydhcplib - Python DHCP client/server library python-pypureomapi - ISC DHCP OMAPI protocol implementation in Python resolvconf - name server information handler wide-dhcpv6-server - DHCPv6 server for automatic IPv6 hosts configuration |
#apt-cache search dhcp server | grep dhcp-server
isc-dhcp-server - ISC DHCP server for automatic IP address assignment isc-dhcp-server-dbg - ISC DHCP server for automatic IP address assignment (debug) isc-dhcp-server-ldap - DHCP server able to use LDAP as backend |
## isc-dhcp-server то что нам надо
|
#apt-get install isc-dhcp-server # инсталляция dhcp-сервера
Reading package lists... Done Building dependency tree Reading state information... Done isc-dhcp-server is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. |
## посмотрим что у него внутри
|
#dpkg -L isc-dhcp-server | wc -l
31 |
## 31 файл
|
## 31dpkg -L isc-dhcp-server | grep /etc
/etc /etc/init.d /etc/init.d/isc-dhcp-server /etc/dhcp /etc/dhcp/dhcpd.conf |
## конÑигÑÑаÐÑÐионнÑÐµÑ ÑайлÑ
|
#â# /etc/init.d/isc-dhcp-server
|
## сартовый скрипт
|
## /etc/dhcp/dhcpd.conf
|
## конфигурационный файл
|
## еÑÑ Ð¾Ð´Ðин:
|
#ls -l /etc/default/isc-dhcp-server
-rw-r--r-- 1 root root 657 Nov 15 06:12 /etc/default/isc-dhcp-server |
## надо интерфейс eth0
|
#cat /etc/default/isc-dhcp-server
# Defaults for isc-dhcp-server initscript # sourced by /etc/init.d/isc-dhcp-server # installed at /etc/default/isc-dhcp-server by the maintainer scripts # # This is a POSIX shell fragment # # Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf). #DHCPD_CONF=/etc/dhcp/dhcpd.conf # Path to dhcpd's PID file (default: /var/run/dhcpd.pid). #DHCPD_PID=/var/run/dhcpd.pid # Additional options to start dhcpd with. # Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead #OPTIONS="" # On what interfaces should the DHCP server (dhcpd) serve DHCP requests? # Separate multiple interfaces with spaces, e.g. "eth0 eth1". INTERFACES="eth1" |
## сейчас eth1
|
#sed -i s/eth1/eth0/ /etc/default/isc-dhcp-server
|
#grep INTER /etc/default/isc-dhcp-server
INTERFACES="eth0" |
## сейчас как надо
|
## проверить есть ли INTERFACES:
|
## дописать в конец файла
|
## еÑеÐÑепеÑÑ ÑконÑигÑÑиÑÑем Ñам DHCP_ÑеÑвеÑ
|
## для тех кто не любит vim
|
#}
![]() 1: ssh: connect to host 192.168.12.1 port 22: No route to host 2: ssh: connect to host 192.168.12.2 port 22: No route to host |
#^C
![]() |
#^C
![]() |
#vim /opt/course-scripts/bin/all
--- /tmp/l3-saved-9664.14429.27691 2014-11-24 08:04:45.912542547 -0500 +++ /opt/course-scripts/bin/all 2014-11-24 08:04:53.580542779 -0500 @@ -1,6 +1,6 @@ for i in `seq 1 8` do -ssh root@192.168.12.$i "$@" 2>&1 | sed "s/^/$i: /" +ssh root@m$i "$@" 2>&1 | sed "s/^/$i: /" done |
#all 'grep -A4 ^subnet /etc/dhcp/dhcpd.conf'
1: subnet 192.168.10.0 netmask 255.255.255.0 { 1: range 192.168.10.100 192.168.10.200; 1: option routers 192.168.10.254; 1: } 2: subnet 192.168.20.0 netmask 255.255.255.0 { 2: range 192.168.20.100 192.168.20.200; 2: } 2: 2: # This declaration allows BOOTP clients to get dynamic addresses, 3: subnet 192.168.30.0 netmask 255.255.255.0 { ... 7: subnet 192.168.70.0 netmask 255.255.255.0 { 7: range 192.168.70.100 192.168.70.200; 7: option routers 192.168.70.254; 7: } 7: 8: subnet 192.168.80.0 netmask 255.255.255.0 { 8: range 192.168.80.100 192.168.80.200; 8: option routers 192.168.80.254; 8: } 8: |
## /перезапустить сервис:
|
#tail /var/log/messages
Nov 24 08:08:24 debian0 dhcpd: Internet Systems Consortium DHCP Server 4.2.2 Nov 24 08:08:24 debian0 dhcpd: Copyright 2004-2011 Internet Systems Consortium. Nov 24 08:08:24 debian0 dhcpd: All rights reserved. Nov 24 08:08:24 debian0 dhcpd: For info, please visit https://www.isc.org/software/dhcp/ Nov 24 08:08:24 debian0 dhcpd: Internet Systems Consortium DHCP Server 4.2.2 Nov 24 08:08:24 debian0 dhcpd: Copyright 2004-2011 Internet Systems Consortium. Nov 24 08:08:24 debian0 dhcpd: All rights reserved. Nov 24 08:08:24 debian0 dhcpd: For info, please visit https://www.isc.org/software/dhcp/ Nov 24 08:08:24 debian0 dhcpd: Wrote 1 leases to leases file. Nov 24 08:08:24 debian0 dhcpd: |
#less /var/log/messages
|
#vim /etc/dhcp/dhcpd.conf
|
#~
|
#vim /etc/dhcp/dhcpd.conf
--- /tmp/l3-saved-9664.14557.14366 2014-11-24 08:09:38.404551381 -0500 +++ /etc/dhcp/dhcpd.conf 2014-11-24 08:09:48.760551700 -0500 @@ -1,13 +1,9 @@ -# вы можете комменты не удалять -# это просто для вас ddns-update-style none; -# доменное имя unix.nt option domain-name "unix.nt"; -# IP-адрес DNS-сервера option domain-name-servers 192.168.12.254; default-lease-time 600; @@ -15,11 +11,8 @@ log-facility local7; -# надо раскомментировать subnet и прописать там свою сеть subnet 192.168.12.0 netmask 255.255.255.0 { range 192.168.12.100 192.168.12.200; option routers 192.168.12.254; } -# это весь файл - |
#less /var/log/messages
|
#dhcpd -i eth0
![]() Internet Systems Consortium DHCP Server 4.2.2 Copyright 2004-2011 Internet Systems Consortium. All rights reserved. Usage: dhcpd [-p <UDP port #>] [-f] [-d] [-q] [-t|-T] [-4|-6] [-cf config-file] [-lf lease-file] [-tf trace-output-file] [-play trace-input-file] [-pf pid-file] [--no-pid] [-s server] [if0 [...ifN]] |
#dhcpd eth0
![]() Internet Systems Consortium DHCP Server 4.2.2 Copyright 2004-2011 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Wrote 1 leases to leases file. No subnet declaration for eth0 (10.1.199.1). ** Ignoring requests on eth0. If this is not what you want, please write a subnet declaration in your dhcpd.conf file for the network segment to which interface eth0 is attached. ** Not configured to listen on any interfaces! |
#ps aux | grep dhcp
root 10627 0.0 0.0 12896 5112 ? Ss 08:10 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth1 root 10648 0.0 0.0 7836 876 pts/5 S+ 08:11 0:00 grep dhcp |
#ps aux | grep dhcpd
root 10627 0.0 0.0 12896 5112 ? Ss 08:10 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth1 root 10657 0.0 0.0 7836 884 pts/5 S+ 08:11 0:00 grep dhcpd |
#ps aux | grep [d]hcpd
root 10627 0.0 0.0 12896 5112 ? Ss 08:10 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth1 |
#ps aux | grep [d]hcpd
root 10627 0.0 0.0 12896 5112 ? Ss 08:10 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth1 |
#ps aux | grep dhcpd
root 10627 0.0 0.0 12896 5112 ? Ss 08:10 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth1 root 10698 0.0 0.0 7836 884 pts/5 S+ 08:11 0:00 grep dhcpd |
#ps aux | grep dhcpd
root 10627 0.0 0.0 12896 5112 ? Ss 08:10 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth1 root 10722 0.0 0.0 7836 880 pts/5 S+ 08:12 0:00 grep dhcpd |
#ps aux | grep [d]hcpd
root 10627 0.0 0.0 12896 5112 ? Ss 08:10 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth1 |
#ps aux | grep [d]hcpd
root 10627 0.0 0.0 12896 5112 ? Ss 08:10 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth1 |
#ps aux | grep dhcpd
root 10627 0.0 0.0 12896 5112 ? Ss 08:10 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth1 root 10791 0.0 0.0 7836 884 pts/5 S+ 08:12 0:00 grep dhcpd |
#all 'ps aux | grep dhcpd'
1: root 7152 0.0 0.0 13024 5496 ? Ss 15:11 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth0 1: root 7174 0.0 0.0 10844 1536 ? Ss 15:12 0:00 bash -c ps aux | grep dhcpd 1: root 7178 0.0 0.0 7836 888 ? S 15:12 0:00 grep dhcpd 2: root 6623 0.0 0.0 13024 5500 ? Ss 15:03 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth0 2: root 6716 0.0 0.0 10848 1544 ? Ss 15:12 0:00 bash -c ps aux | grep dhcpd 2: root 6720 0.0 0.0 7836 880 ? S 15:12 0:00 grep dhcpd 3: root 5789 0.0 0.0 13024 5496 ? Ss 15:10 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth0 3: root 5806 0.0 0.0 10848 1544 ? Ss 15:12 0:00 bash -c ps aux | grep dhcpd 3: root 5810 0.0 0.0 7836 884 ? S 15:12 0:00 grep dhcpd 4: root 6192 0.0 0.0 31404 2864 pts/5 S+ 14:56 0:00 /usr/bin/vim /etc/dhcp/dhcpd.conf ... 5: root 6658 0.0 0.0 7836 884 ? S 15:12 0:00 grep dhcpd 6: root 7472 0.0 0.0 13024 5544 ? Ss 15:06 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth0 6: root 7535 0.0 0.0 10848 1544 ? Ss 15:12 0:00 bash -c ps aux | grep dhcpd 6: root 7539 0.0 0.0 7836 888 ? S 15:12 0:00 grep dhcpd 7: root 9012 0.0 0.0 13024 5620 ? Ss 15:06 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth0 7: root 9095 0.0 0.0 10844 1536 ? Ss 15:13 0:00 bash -c ps aux | grep dhcpd 7: root 9099 0.0 0.0 7836 884 ? S 15:13 0:00 grep dhcpd 8: root 7230 0.0 0.0 13024 5524 ? Ss 15:09 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth0 8: root 7253 0.0 0.0 10844 1532 ? Ss 15:13 0:00 bash -c ps aux | grep dhcpd 8: root 7257 0.0 0.0 7836 888 ? S 15:13 0:00 grep dhcpd |
#host 192.168.12.254
![]() Host 254.12.168.192.in-addr.arpa. not found: 3(NXDOMAIN) |
#ssh m1
Linux debian1 3.2.0-4-amd64 #1 SMP Debian 3.2.63-2+deb7u1 x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Mon Nov 24 14:44:46 2014 from 192.168.12.254 l3-agent is already running: pid=3718; pidfile=/root/.lilalo/l3-agent.pid |
#route
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 192.168.10.254 0.0.0.0 UG 0 0 0 eth0 192.168.10.0 * 255.255.255.0 U 0 0 0 eth0 |
#cat /etc/resolv.conf
nameserver 192.168.12.254 search unix.nt |
#exit
exit Connection to m1 closed. |
#vim /etc/bind/
![]() |
#vim /etc/bind/
![]() |
#vim /etc/bind/named.conf.local
|
#~
![]() named.conf named.conf.local named.conf.default-zones named.conf.options |
#vim /etc/bind/named.conf.default-zones
--- /tmp/l3-saved-9664.19971.25888 2014-11-24 08:16:08.016563159 -0500 +++ /etc/bind/named.conf.default-zones 2014-11-24 08:16:42.528564166 -0500 @@ -27,4 +27,9 @@ file "/etc/bind/db.255"; }; +zone "168.192.in-addr.arpa" { + type master; + file "/etc/bind/db.192.168"; +}; + |
#ls /etc/bind/db.
![]() db.0 db.127 db.255 db.empty db.local db.root |
#ls /etc/bind/db.
![]() db.0 db.127 db.255 db.empty db.local db.root |
#cp /etc/bind/db.127 /etc/bind/db.192.168
|
#vim /etc/bind/db.192.168
--- /tmp/l3-saved-9664.9602.3312 2014-11-24 08:17:02.284564794 -0500 +++ /etc/bind/db.192.168 2014-11-24 08:19:31.728569312 -0500 @@ -11,3 +11,23 @@ ; @ IN NS localhost. 1.0.0 IN PTR localhost. + +1.10 IN PTR m1.unix.nt. +254.10 IN PTR switch.unix.nt. +1.20 IN PTR m2.unix.nt. +254.20 IN PTR switch.unix.nt. +1.30 IN PTR m3.unix.nt. +254.30 IN PTR switch.unix.nt. +1.40 IN PTR m4.unix.nt. +254.40 IN PTR switch.unix.nt. +1.50 IN PTR m5.unix.nt. +254.50 IN PTR switch.unix.nt. +1.60 IN PTR m6.unix.nt. +254.60 IN PTR switch.unix.nt. +1.70 IN PTR m7.unix.nt. +254.70 IN PTR switch.unix.nt. +1.80 IN PTR m8.unix.nt. +254.80 IN PTR switch.unix.nt. +1.90 IN PTR m9.unix.nt. +254.90 IN PTR switch.unix.nt. + |
#/etc/init.d/bind9 restart
Stopping domain name service...: bind9waiting for pid 2466 to die . Starting domain name service...: bind9. |
#host 192.168.10.1
1.10.168.192.in-addr.arpa domain name pointer m1.unix.nt. |
#touch .hushlogin
|
#exit
exit Connection to m1 closed. |
#ssh m1
Linux debian1 3.2.0-4-amd64 #1 SMP Debian 3.2.63-2+deb7u1 x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Mon Nov 24 15:13:19 2014 from 192.168.12.254 l3-agent is already running: pid=3718; pidfile=/root/.lilalo/l3-agent.pid |
#route
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default switch.unix.nt 0.0.0.0 UG 0 0 0 eth0 192.168.10.0 * 255.255.255.0 U 0 0 0 eth0 |
#exit
exit Connection to m1 closed. |
#ssh m1
l3-agent is already running: pid=3718; pidfile=/root/.lilalo/l3-agent.pid |
#/etc/init.d/isc-dhcp-server restart
![]() Stopping ISC DHCP server: dhcpd failed! Starting ISC DHCP server: dhcpdcheck syslog for diagnostics. ... failed! failed! |
#ssh m4
Linux debian4 3.2.0-4-amd64 #1 SMP Debian 3.2.63-2+deb7u1 x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Mon Nov 24 14:45:21 2014 from 192.168.12.254 l3-agent is already running: pid=3844; pidfile=/root/.lilalo/l3-agent.pid |
#vim /etc/dhcp/dhcpd.conf
|
#/etc/init.d/isc-dhcp-server restart
Stopping ISC DHCP server: dhcpd failed! Starting ISC DHCP server: dhcpd. |
#ps aux | grep [d]hcp
root 6192 0.0 0.0 31404 2864 pts/5 S+ 14:56 0:00 /usr/bin/vim /etc/dhcp/dhcpd.conf root 6330 0.0 0.0 31412 2924 pts/3 S+ 15:14 0:00 /usr/bin/vim /etc/dhcp/dhcpd.conf root 6587 0.0 0.0 13024 5620 ? Ss 15:23 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth0 |
#kill 6192 6330
|
#ps aux | grep [d]hcp
root 6587 0.0 0.0 13024 5620 ? Ss 15:23 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid eth0 |
#exit
exit Connection to m4 closed. |
#find /var/ -name \*leases\*
/var/lib/dhcp/dhclient.eth0.leases /var/lib/dhcp/dhcpd.leases /var/lib/dhcp/dhclient.leases /var/lib/dhcp/dhcpd.leases~ |
#cat /var/lib/dhcp/dhcpd.leases
# The format of this file is documented in the dhcpd.leases(5) manual page. # This lease file was written by isc-dhcp-4.2.2 lease 192.168.12.200 { starts 1 2014/11/24 07:29:01; ends 1 2014/11/24 07:39:01; tstp 1 2014/11/24 07:39:01; cltt 1 2014/11/24 07:29:01; binding state free; hardware ethernet 6c:3b:e5:39:37:4b; uid "\001l;\34597K"; } server-duid "\000\001\000\001\033\371\361\265\000\033!\235Z\004"; |
#all 'grep ^lease /var/lib/dhcp/dhcpd.leases'
1: lease 192.168.10.100 { 1: lease 192.168.10.101 { 1: lease 192.168.10.100 { 1: lease 192.168.10.101 { 1: lease 192.168.10.100 { 1: lease 192.168.10.101 { 2: lease 192.168.20.100 { 2: lease 192.168.20.101 { 2: lease 192.168.20.100 { 2: lease 192.168.20.101 { ... 7: lease 192.168.70.100 { 7: lease 192.168.70.101 { 7: lease 192.168.70.100 { 7: lease 192.168.70.101 { 8: lease 192.168.80.100 { 8: lease 192.168.80.101 { 8: lease 192.168.80.100 { 8: lease 192.168.80.101 { 8: lease 192.168.80.100 { 8: lease 192.168.80. |