quarta-feira, 29 de junho de 2011

Linux DHCP Server atribuindo IP pelo Option-82 Circuit-ID



Instalando o DHCPD no linux (UBUNTU/DEBIAN)

1º ) Instalando DHCPD

# apt-get install dhcp3-server

2º) Configurando syslog

# vi /etc/rsyslog.d/S50default.conf

Inserir as linhas:

#
#  DHCP3-SERVER LOG
#
local7.debug            /var/log/dhcpd.log


3º) Criar arquivo de log

# touch /var/log/dhcpd.log

3º) Reiniciar o SYSLOG:

# service rsyslog restart

4º) Inserir no dhcpd.conf a linha:

log-facility local7;


5º) Iniciar o DHCP Server:

#/etc/init.d/dhcp3-server start


6º) Realizando DEBUG:

Inserir no dhcpd.conf o comando para debug:

log ( info, option agent.circuit-id );


Isso fará com quem apareça no log /var/log/dhcpd.log as informações do client dhcp, mas isso apenas se ocorrer o lease do ip!!!
Então o ideal é criar uma configuração bem básica que atribua um ip para o cliente, apenas para poder ver no log as informaçãos do pedido DHCP do cliente.
 

Exemplo: root@ubuntu:/etc/dhcp3# cat dhcpd.conf
 

ddns-update-style none;
option domain-name "meudomain";
option domain-name-servers 8.8.8.8;

default-lease-time 600;
max-lease-time 7200;

# habilitar local7 como dhcp no syslog
log-facility local7;

subnet 192.168.20.0 netmask 255.255.255.0 {
  range 192.168.20.10 192.168.20.20;
  option routers 192.168.20.1;
}

# ELE SO LOGA NO OFFER
log( info, option agent.circuit-id);


Verificar no LOG as informações de circuit-id:

# tail –f /var/log/dhcpd.log

Jun 29 10:45:06 ubuntu dhcpd: olt1-gpon xpon 0/1/0/0:0.40.40
Jun 29 10:45:06 ubuntu dhcpd: DHCPREQUEST for 192.168.20.40 from 00:11:11:90:5b:29 (clientpc) via eth0
Jun 29 10:45:06 ubuntu dhcpd: DHCPACK on 192.168.20.10 to 00:11:11:90:5b:29 (clientpc) via eth0




 
Também é possível verificar no leases:

root@ubuntu:/etc/dhcp3# tail -f /var/lib/dhcp3/dhcpd.leases
  starts 3 2011/06/29 13:45:06;
  ends 3 2011/06/29 13:55:06;
  cltt 3 2011/06/29 13:45:06;
  binding state active;
  next binding state free;
  hardware ethernet 00:11:11:90:5b:29;
  uid "\001\000\021\021\220[)";
  option agent.circuit-id "olt1-gpon xpon 0/1/0/0:0.40.40";
  client-hostname "clientpc";

Este circuit-id está sendo inserido como string pelo roteador.


Agora que sabemos qual o circuit-id, podemos criar uma configuração para entregar os IPs baseados no circuit-ID de cada usuário:


ddns-update-style none;
option domain-name "mydomain";
option domain-name-servers 8.8.8.8;

default-lease-time 600;
max-lease-time 7200;

# habilitar local7 como dhcp no syslog
log-facility local7;

subnet 192.168.20.0 netmask 255.255.255.0 {
  option routers 192.168.20.1;

  class "uservlan40" {
        match if option agent.circuit-id = "olt1-gpon xpon 0/1/0/0:0.40.40";
  }

  pool {
        range 192.168.20.40;
        allow members of "uservlan40";
  }

  class "uservlan30" {
        match if option agent.circuit-id = "olt1-gpon xpon 0/1/0/0:0.30.30";
  }

  pool {
        range 192.168.20.30;
        allow members of "uservlan30";
  }
}

# ELE SO LOGA NO OFFER
log( info, option agent.circuit-id);



Também é interessande deixar o WIRESHARK capturando pacotes, e colocar como filtro "bootp" para filtrar apenas os pacotes de DHCP. Pelo wireshark é possível ver todas as options do pacote DHCP, circuit-id e remote-id.




Linux Ubuntu losing static IP address on disconnect

If you are losing the interface static IP address on disconnect in your Linux Ubuntu 9.x , this happens because Ubuntu has its own network manager and probably you're trying to configure the static IP in the usual way, editing the config file /etc/network/interfaces.

There are two solutions:


1) Use the Network-Manager

1.1) Remove all manually configurations from /etc/network/interfaces

The file  /etc/network/interfaces  should be like this:

auto lo
iface lo inet loopback

 1.2) Configure your network interface static IP address through the Network-Manager in Gnome panel.

1.3) Restart Network-Manager service:

# service network-manager restart
 

2) Stop Network-Manager Service

2.1) Stop Network-Manager service with:


# service network-manager stop

2.2) To permanently disable Network-Manager
edit /etc/init/network-manager.conf and comment the line

## exec NetworkManager

2.3) Configure your network in the usual way (manually), editing /etc/network/interfaces

# vi /etc/network/interfaces 
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.1

Restart the network service:


# ./etc/init.d/networking restart

For more information about this issue: 
  1. http://en.kioskea.net/faq/979-having-a-static-ip-address-under-ubuntu-8-10
  2. http://www.cyberciti.biz/faq/setting-up-an-network-interfaces-file/

I hope this information helps.





Atualização DELL INSPIRON 15R com Update para Windows 10 22H2 travado em 61% ou 99%

 Como atualizar notebook DELL INSPIRON 15R com Windows 10 que está com a atualização travada em 61% ou 99%: Processo de atualização manual d...