marce-lost
(usa Debian)
Enviado em 24/04/2017 - 14:24h
Boa tarde!
Eu não entendo muito e fiz pelo passo a passo abaixo.
eth0 cabo internet
eth1 cabo rede
ifconfig para ver as placas
instalar o serviço de DHCP
apt-get install isc-dhcp-server
editar o arquivo
nano /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
auto eth0
iface eth0 inet dhcp
allow-hotplug eth1
auto eth1
iface eth1 inet static
address 192.168.10.1
netmask 255.255.255.0
network 192.168.10.0
broadcast 192.168.1.255
depois subir a placa
ifup eth1
agora editar o arquivo
nano /etc/dhcp/dhcpd.conf
#
# 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...
option domain-name "laoa";
option domain-name-servers 200.189.80.136, 8.8.8.8;
default-lease-time 600;
max-lease-time 7200;
# 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.12.187.0 netmask 255.255.255.0 {
#}
# This is a very basic subnet declaration.
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.10 192.168.10.254;
option subnet-mask 255.255.255.0;
option routers 192.168.10.1;
option broadcast-address 192.168.10.255;
}
# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.
testar verificar se tem algum erro
dhcpd -t
Editar o arquivo e colocar no final a placa eth1
nano /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"
comando para testar o serviço de dhcp
service isc-dhcp-server start ou restart ou stop ou status
arp -n verifica os ips que estão conectados
Configurar o roteamento de pacotes e criar um arquivo chamado NAT
nano /usr/local/bin/nat
colocar abaixo os comandos
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
ok salvar e sair
Dar permissão de acesso
chmod +x /usr/local/bin/nat
Colocar o arquivo para iniciar junto com o sistema
nano /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/usr/local/bin/nat
exit 0