Howto dhcp server: Difference between revisions
Mandulete1 (talk | contribs) No edit summary |
Mandulete1 (talk | contribs) No edit summary |
||
Line 22: | Line 22: | ||
make sure you have network-manager installed: | make sure you have network-manager installed: | ||
yum install networkmanager -y | yum install networkmanager -y | ||
start and enable networkmanager: | |||
systemctl start NetworkManager | systemctl start NetworkManager | ||
systemctl enable NetworkManager | systemctl enable NetworkManager | ||
erase default network profiles: | |||
nmcli con del eth0 | nmcli con del eth0 | ||
nmcli con del eth1 | nmcli con del eth1 | ||
nmcli con del Wired\ connection\ 1 | nmcli con del Wired\ connection\ 1 | ||
nmcli con del Wired\ connection\ 2 | nmcli con del Wired\ connection\ 2 | ||
configure network interfaces nmcli: | |||
nmcli con add con-name eth0 ipv4.method manual type ethernet ifname eth0 ipv4.addresses 192.168.75.254/24 ipv4.gateway 192.168.75.1 ipv4.dns 4.2.2.1,4.2.2.2 autoconnect yes | nmcli con add con-name eth0 ipv4.method manual type ethernet ifname eth0 ipv4.addresses 192.168.75.254/24 ipv4.gateway 192.168.75.1 ipv4.dns 4.2.2.1,4.2.2.2 autoconnect yes | ||
nmcli con add con-name eth1 ipv4.method manual type ethernet ifname eth1 ipv4.addresses 192.168.33.1/24 autoconnect yes | nmcli con add con-name eth1 ipv4.method manual type ethernet ifname eth1 ipv4.addresses 192.168.33.1/24 autoconnect yes |
Revision as of 17:22, 2 August 2020
first we install the required package:
yum install dhcp -y
edit the dhcp server configuration file at /etc/dhcp/dhcpd.conf:
server-identifier server; ddns-update-style ad-hoc; shared-network DHCP { option subnet-mask 255.255.255.0; subnet 192.168.33.0 netmask 255.255.255.0 { range 192.168.33.100 192.168.33.150; option broadcast-address 192.168.33.255; option routers 192.168.33.1; option domain-name "cdqgroup.com"; option domain-name-servers 192.168.33.1; default-lease-time 600; max-lease-time 7200; } }
in our server we need configure our network interfaces:
- eth0 interface connected to the internet
- eth1 interface connected to lan
make sure you have network-manager installed:
yum install networkmanager -y
start and enable networkmanager:
systemctl start NetworkManager systemctl enable NetworkManager
erase default network profiles:
nmcli con del eth0 nmcli con del eth1 nmcli con del Wired\ connection\ 1 nmcli con del Wired\ connection\ 2
configure network interfaces nmcli:
nmcli con add con-name eth0 ipv4.method manual type ethernet ifname eth0 ipv4.addresses 192.168.75.254/24 ipv4.gateway 192.168.75.1 ipv4.dns 4.2.2.1,4.2.2.2 autoconnect yes nmcli con add con-name eth1 ipv4.method manual type ethernet ifname eth1 ipv4.addresses 192.168.33.1/24 autoconnect yes
Para reservar un IP en especifico a una maquina hacemos lo a traves de hardware address siguiente:
host lab3 { hardware ethernet 00:40:F4:A8:60:5E; fixed-address 192.168.2.3; }
Debemos asignar la interface que estara repartiendo IP, editamos el archivo /etc/sysconfig/dhcpd:
DHCPDARGS=eth0
Luego de esto subimos el servicio de dhcpd con el siguiente comando
service dhcpd start
Se supone que si tenemos dos interface una de ellas se conecta al internet y otra reparte IP con el servidor DHCP que acabamos de configurar, y lo que deseamos es compartir este internet que viene de la otra interface con la red que esta tomando IP de nuestro servidor DHCP, utilizamos los siguientes comandos para establecer reglas con IPTABLES que nos permitan lograrlo:
iptables --table nat --append POSTROUTING --out-interface INTERNET -j MASQUERADE iptables --append FORWARD --in-interface NETWORK -j ACCEPT echo 1 > /proc/sys/net/ipv4/ip_forward
INTERNET = eth0 NETWORK = eth1