Показать полную графическую версию : Web, DHCH сервер
mdk666666
04-09-2016, 14:31
Планирую сделать web и dhcp сервер на основе старого компа. Установил isc-dhcp-server. Интернет подается на eth1, а с eth0 он должен идти на ПК с windows. Обнаружил, что в /etc/network/interfaces нет eth0. Добавил строчку
auto eth0
iface eth0 inet dhcp
Далее настроил isc-dhcp-server и прописал в файле /etc/dhcp/dhcpd.conf:
default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.254;
option domain-name-servers 192.168.1.1, 192.168.1.2;
option domain-name "workgroup";
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.100;
range 192.168.1.150 192.168.1.200;
}
в файле /etc/default/isc-dhcp-server выбрал
INTERFACES="eth0"
Но ничего не заработало. Что я делаю не так? Может витую пару не так обжал(пк-пк или пк-свич?)?
ruslandh
04-09-2016, 14:59
Может витую пару не так обжал »
Посмотрите есть-ли линк (link на интерфейсе)
ethtool eth0
mdk666666
04-09-2016, 15:09
Посмотрите есть-ли линк (link на интерфейсе) »
Линк есть, даже IP получаю, вот только этот IP я нигде не прописывал, он вообще левый
ruslandh
04-09-2016, 15:21
Какой ip у eth0 ? какая маска сети на нём.
Короче, что выдаёт
ifconfig eth0
auto eth0 iface eth0 inet dhcp »
не понял - на сервере должен быть статический ip.
mdk666666
04-09-2016, 15:44
Короче, что выдаёт
ifconfig eth0 »
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:19:5b:33:8a:0d
inet6 addr: fe80::219:5bff:fe33:8a0d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:983025 overruns:0 frame:983025
TX packets:0 errors:2 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:912 (912.0 B) TX bytes:0 (0.0 B)
У меня авто ip всегда один и тот же, выдается по мак на eth1
А вот и настройки интерфейсов:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth1 eth0
iface eth1 inet dhcp
# This is an autoconfigured IPv6 interface
iface eth1 inet6 auto
iface eth0 inet dhcp
ruslandh
04-09-2016, 16:19
У меня авто ip всегда один и тот же, выдается по мак на eth1 »
Мы-же не про eth1 говорим. У eth0 должен быть статический адрес, из сети
192.168.1.0 netmask 255.255.255.0
и судя по
option routers 192.168.1.254;
Равный 192.168.1.254
option domain-name-servers 192.168.1.1, 192.168.1.2;
option domain-name "workgroup";
А это кто такие?
mdk666666
04-09-2016, 16:25
Прописал
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth1 eth0
iface eth1 inet dhcp
# This is an autoconfigured IPv6 interface
iface eth1 inet6 auto
iface eth0 inet static
address 192.168.1.254
netmask 255.255.255.0
gateway 192.168.1.0
Теперь выдает:
# ifdown eth0
ifdown: interface eth0 not configured
# ifup eth0
RTNETLINK answers: File exists
Failed to bring up eth0.
и SSH отвалился при попытке рестарта сети, нужно идти вытягивать кабель из eth0
ruslandh
04-09-2016, 16:33
# ifdown eth0 ifdown: interface eth0 not configured # ifup eth0 RTNETLINK answers: File exists Failed to bring up eth0. »
Это уже "приколы" конкретного дистрибутива. У меня синаксис другой, и поведение другое
SSH отвалился при попытке рестарта сети, »
А он-то каким боком? как он связан с eth0?
gateway 192.168.1.0 »
не понял - gateway тут вообще не нужен - сервер сам шлюз. Это лишнее.
mdk666666
04-09-2016, 17:13
не понял - gateway тут вообще не нужен - сервер сам шлюз. Это лишнее. »
Тогда я не понимаю, куда прописывать Мы-же не про eth1 говорим. У eth0 должен быть статический адрес, из сети
192.168.1.0 netmask 255.255.255.0
и судя по
option routers 192.168.1.254;
Равный 192.168.1.254 »
Сорри, я новичек
ruslandh
04-09-2016, 17:52
Тогда я не понимаю, куда прописывать »
А никуда. Вы клиентам через dhcp посылаете, что вы шлюз. Достаточно того, что-бы был включён форвадер (перекидывния запросов с одного интерфейса на другой).
Сорри, я новичек »
Тогда вам стоит почитать теорию как всё это работает.
http://samag.ru/archive/article/2066
mdk666666
04-09-2016, 18:49
Прочитал, интересная статья, но не совсем то. Я обнаружил что у меня не настроен субнет на eth1 (который инет), если это не та сеть которая вам нужна:
# dhcpd
Internet Systems Consortium DHCP Server 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Config file: /etc/dhcp/dhcpd.conf
Database file: /var/lib/dhcp/dhcpd.leases
PID file: /var/run/dhcpd.pid
Wrote 1 leases to leases file.
No subnet declaration for eth1 (159.XXX.XX.45).
** Ignoring requests on eth1. If this is not what
you want, please write a subnet declaration
in your dhcpd.conf file for the network segment
to which interface eth1 is attached. **
Listening on LPF/eth0/00:19:5b:33:8a:0d/192.168.1.0/24
Sending on LPF/eth0/00:19:5b:33:8a:0d/192.168.1.0/24
Sending on Socket/fallback/fallback-net
There's already a DHCP server running.
root@E1sys:/home/elsys#
If you think you have received this message due to a bug rather
than a configuration issue please read the section on submitting
bugs on either our web page at www.isc.org or in the README file
before submitting a bug. These pages explain the proper
process and the information we find helpful for debugging..
exiting.
#
# Sample configuration file for ISC dhcpd for Debian
#
#
# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;
# option definitions common to all supported networks...
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.150 192.168.1.200;
option routers 192.168.1.254;
option domain-name-servers 192.168.1.1, 192.168.1.2;
option domain-name "workgroup";
}
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
#subnet 10.152.187.0 netmask 255.255.255.0 {
#}
# This is a very basic subnet declaration.
#subnet 10.254.239.0 netmask 255.255.255.224 {
# range 10.254.239.10 10.254.239.20;
# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
#}
# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.
#subnet 10.254.239.32 netmask 255.255.255.224 {
# range dynamic-bootp 10.254.239.40 10.254.239.60;
# option broadcast-address 10.254.239.31;
# option routers rtr-239-32-1.example.org;
#}
# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
# range 10.5.5.26 10.5.5.30;
# option domain-name-servers ns1.internal.example.org;
# option domain-name "internal.example.org";
# option routers 10.5.5.1;
# option broadcast-address 10.5.5.31;
# default-lease-time 600;
# max-lease-time 7200;
#}
# Hosts which require special configuration options can be listed in
# host statements. If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.
#host passacaglia {
# hardware ethernet 0:0:c0:5d:bd:95;
# filename "vmunix.passacaglia";
# server-name "toccata.fugue.com";
#}
# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
#host fantasia {
# hardware ethernet 08:00:07:26:c0:a5;
# fixed-address fantasia.fugue.com;
#}
# You can declare a class of clients and then do address allocation
# based on that. The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.
#class "foo" {
# match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
#}
#shared-network 224-29 {
# subnet 10.17.224.0 netmask 255.255.255.0 {
# option routers rtr-224.example.org;
# }
# }
# pool {
# allow members of "foo";
# range 10.17.224.10 10.17.224.250;
# }
# pool {
# deny members of "foo";
# range 10.0.29.10 10.0.29.230;
# }
#}
ruslandh
04-09-2016, 19:14
Нет, вы логику работы не понимаете.
У сервера на eth0 должен быть статический адрес, и он компам, обращаемся к нему по этому интерфейсу раздёт ip адреса, настройки шлюза и dns, так, что-бы компы могли выйти в интернет - его субсеть.
А все другие интерфейсы не должны работать с dhcp, вот если -бы надо было раздавать адреса на других интерфейсах, тогда надо было сделать аналогичное и для них.
Тот интерфейс, который смотрит в инет, в общем случае также получает всё это от dhcp более высокого уровня (например провайдера). А вам надо раздать адреса в своей подсети, висящей на eth0.
Более того, если на eth0 висит только один комп, то можно вообще не использовать dhcp, а всё это прописать статически на клиенте (что присылает обчно dhcp).
MakaBooka
05-09-2016, 16:44
Ваша внутренняя сеть - eth0, static ip, на нём слушает iscdhcpd и всем желающим раздаёт ip из своей подсети (точнее из пула, которые в ней выделен).
так понятнее?
mdk666666
10-09-2016, 20:31
Я уже 20 раз все перенастроил, внешний eth1, внутренний eth 0. Я уже сетевуху сменил, кабель поменял.
настроил несколькими способами. Последний из них:
server-name DERPian;
authoritative;
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.0.255;
option domain-name "workgroup";
range 192.168.0.4 192.168.0.222;
option domain-name-servers 192.168.0.1, 8.8.8.8;
option ip-forwarding off;
default-lease-time 43200;
max-lease-time 86400;
host DERPian {
hardware ethernet 00:13:60:86:04:8b;
fixed-address 192.168.0.3;
option subnet-mask 255.255.255.0;
option host-name "DERPian";
}
}
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth1
iface eth1 inet dhcp
allow-hotplug eth0
iface eth0 inet static
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
В /etc/sysctl.conf заменил строку net.ipv4.ip_forward=0 на net.ipv4.ip_forward=1
Добавил в /etc/rc.local строчку iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
Ничего не помогает, интернета нет.
ruslandh
10-09-2016, 21:47
gateway 192.168.0.1 »
Нафига вы указываете в настройках eth0 gateway 192.168.0.1 ?
option ip-forwarding off; »
Это зачем.
Рекомендую вам расписать тут каждую строчку - как вы это понимаете.
mdk666666
10-09-2016, 22:11
Рекомендую вам расписать тут каждую строчку - как вы это понимаете. »
Я не знаю зачем, но пускай:
server-name DERPian; \\Рандомное имя сервера
authoritative; \\Единственный и неповторимый DHCP сервер в сети
ddns-update-style interim; \\Наверное указывает на то, кто кому, как и когда выдаст данные ipv4
ignore client-updates; \\Игнорировать клиентов и их запросы на смену/получение IP
subnet 192.168.0.0 netmask 255.255.255.0 { \\Задаем в какой подсети будут находятся клиенты
option routers 192.168.0.1; \\ IP DHCP сервера?
option subnet-mask 255.255.255.0; \\ фиг знает, широковещательный сигнал по этому адресу?
option broadcast-address 192.168.0.255; \\ Н.Д.
option domain-name "workgroup"; \\ Название сети, может быть произвольным
range 192.168.0.4 192.168.0.222; \\ пул IP адресов
option domain-name-servers 192.168.0.1, 8.8.8.8; \\Сервера доменных имен, я не знаю что указать, кто-то указывает IP сервера, кто-то ip гугля
option ip-forwarding off; \\ Сделал как в гайде, потом закомментировал эффект нулевой
default-lease-time 43200; \\Время аренды?
max-lease-time 86400; \\Макс время аренды?
host DERPian { \\Дальше идет что-то непонятное просто сделал как по аналогии
hardware ethernet 00:13:60:86:04:8b;
fixed-address 192.168.0.3;
option subnet-mask 255.255.255.0;
option host-name "DERPian";
}
}
allow-hotplug eth0 \\ Разрешить "Горячую замену"
iface eth0 inet static \\ Включить стат IP
address 192.168.0.1 \\ Адрес
netmask 255.255.255.0 \\ Маска подсети
network 192.168.0.0 \\ Сеть????
broadcast 192.168.0.255 \\Хм...
gateway 192.168.0.1 \\Адрес шлюза, мб адрес моего шлюза?
ruslandh
10-09-2016, 22:24
Удалите последнюю строчку.
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.