14.04 Partilhar Internet com 2 placas de rede

2

Eu uso um Ubuntu 14.04 32 bits

Eu tenho o seguinte problema, eu tenho que compartilhar Internet: 1 Internet Server (eth1) 1 Encaminhar Internet com outras placas de rede (esta é a máquina que precisa configurar - eth2) Clientes Pcs.

A Internet vem com um cabo de rede para o servidor e a outra placa de rede vai para um switch que distribui para micro clientes.

A pergunta é: como faço para obter a Internet uma placa de rede e distribuir a outra?

Obrigado em avançado.

Por favor, veja meu syslog

    May  7 10:40:37 asterisk dhcpd: options subnet-mask 
    May  7 10:40:37 asterisk dhcpd:          ^
    May  7 10:40:37 asterisk dhcpd: /etc/dhcp/dhcpd.conf line 6: semicolon expected.
    May  7 10:40:37 asterisk dhcpd: options broadcast-address 
    May  7 10:40:37 asterisk dhcpd:          ^
    May  7 10:40:37 asterisk dhcpd: /etc/dhcp/dhcpd.conf line 7: semicolon expected.
    May  7 10:40:37 asterisk dhcpd: options routers 
    May  7 10:40:37 asterisk dhcpd:          ^
    May  7 10:40:37 asterisk dhcpd: /etc/dhcp/dhcpd.conf line 8: semicolon expected.
    May  7 10:40:37 asterisk dhcpd: options domain-name-servers 
    May  7 10:40:37 asterisk dhcpd:          ^
    May  7 10:40:37 asterisk dhcpd: /etc/dhcp/dhcpd.conf line 9: semicolon expected.
    May  7 10:40:37 asterisk dhcpd: options domain-name 
    May  7 10:40:37 asterisk dhcpd:          ^
    May  7 10:40:37 asterisk dhcpd: Configuration file errors encountered -- exiting
    May  7 10:40:37 asterisk dhcpd: Internet Systems Consortium DHCP Server 4.2.2
    May  7 10:40:37 asterisk dhcpd: Copyright 2004-2011 Internet Systems Consortium.
    May  7 10:40:37 asterisk dhcpd: All rights reserved.
    May  7 10:40:37 asterisk dhcpd: For info, please visit         https://www.isc.org/software/dhcp/
    May  7 10:40:37 asterisk dhcpd: /etc/dhcp/dhcpd.conf line 5: semicolon expected.
    May  7 10:40:37 asterisk dhcpd: options subnet-mask 
    May  7 10:40:37 asterisk dhcpd:          ^
    May  7 10:40:37 asterisk dhcpd: /etc/dhcp/dhcpd.conf line 6: semicolon expected.
    May  7 10:40:37 asterisk dhcpd: options broadcast-address 
    May  7 10:40:37 asterisk dhcpd:          ^
    May  7 10:40:37 asterisk dhcpd: /etc/dhcp/dhcpd.conf line 7: semicolon expected.
    May  7 10:40:37 asterisk dhcpd: options routers 
    May  7 10:40:37 asterisk dhcpd:          ^
    May  7 10:40:37 asterisk dhcpd: /etc/dhcp/dhcpd.conf line 8: semicolon expected.
    May  7 10:40:37 asterisk dhcpd: options domain-name-servers 
    May  7 10:40:37 asterisk dhcpd:          ^
    May  7 10:40:37 asterisk dhcpd: /etc/dhcp/dhcpd.conf line 9: semicolon expected.
    May  7 10:40:37 asterisk dhcpd: options domain-name 
    May  7 10:40:37 asterisk dhcpd:          ^
    May  7 10:40:37 asterisk dhcpd: Configuration file errors encountered -- exiting
    May  7 10:40:49 asterisk dhcpd: Wrote 0 leases to leases file.
    May  7 10:40:49 asterisk dhcpd: 
    May  7 10:40:49 asterisk dhcpd: No subnet declaration for eth2 (no IPv4 addresses).
    May  7 10:40:49 asterisk dhcpd: ** Ignoring requests on eth2.  If this is not what
    May  7 10:40:49 asterisk dhcpd:    you want, please write a subnet declaration
    May  7 10:40:49 asterisk dhcpd:    in your dhcpd.conf file for the network segment
    May  7 10:40:49 asterisk dhcpd:    to which interface eth2 is attached. **
    May  7 10:40:49 asterisk dhcpd: 
    May  7 10:40:49 asterisk dhcpd: 
    May  7 10:40:49 asterisk dhcpd: Not configured to listen on any interfaces!
    
por Vitor Mazuco 29.04.2015 / 21:22

1 resposta

2

A primeira coisa a fazer é ativar o encaminhamento de IP. Isso é feito usando

echo "1" > /proc/sys/net/ipv4/ip_forward

Em seguida, adicionaremos uma regra para encaminhar o tráfego

iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT

e finalmente, pedimos ao IPtables para se mascarar

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Editar 1

Instalar

sudo apt-get install isc-dhcp-server

configure

sudo nano -w /etc/dhcp/dhcpd.conf

# Sample /etc/dhcpd.conf
# (add your comments here) 
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 "mydomain.example";

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;
} 

reiniciar o serviço

sudo service isc-dhcp-server restart
    
por 2707974 30.04.2015 / 09:45