Busca de lista [RESOLVIDO]

1. Busca de lista [RESOLVIDO]

Lucas Peregrino
Lucas Peregrino

(usa Debian)

Enviado em 19/09/2017 - 21:25h

Boa noite estou tentado puxar duas lista de um único arquivo individualizante consigo mas junto estou tendo problema alguem poderia me dar uma ajuda.

cat /etc/dhcp/dhcpd.conf

host Estacao {
allow client-updates;
allow unknown-clients;
hardware ethernet 00:11:23:9e:a1:e2;
fixed-address 192.168.30.71;
}

Gostaria de lista um do lado do outro se possivel. Para saber se interface ja foi cadastrada com outro ip.

hardware ethernet 00:27:22:8e:a7:e8; fixed-address 192.168.3.71;




  


2. MELHOR RESPOSTA

Marcelo Oliver
msoliver

(usa Debian)

Enviado em 23/09/2017 - 13:45h

Lucas Peregrino escreveu:

grep -E -A3 'clients;$' /etc/dhcp/dhcpd.conf |awk -F '[" " "\n"]' 'BEGIN{RS="--\n";} {print $26 $27}'unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;


grep -E -A3 'ethernet|fixed-address;$' /etc/dhcp/dhcpd.conf | awk -F '[" " "\n"]' 'BEGIN {RS="--\n";} {print $26 $27}'
ethernet54:9f:35:0d:0c:ae;
ethernet08:00:27:81:10:58;
ethernet08:00:27:f7:02:af;
ethernet08:00:27:bf:5c:f9;
ethernet00:bb:46:14:4f:b9;
ethernet00:1d:ba:92:64:b6;
ethernet70:4d:7b:62:90:63;
ethernet48:5b:39:ce:fd:0b;
ethernet94:de:80:03:b0:db;
ethernet50:e5:49:f3:9c:1f;
ethernet4c:ed:de:c5:1e:7f;
ethernete0:b9:a5:0c:3c:d6;
ethernet6c:62:6d:30:b0:df;
ethernet44:6d:57:33:74:5d;
ethernetac:16:2d:34:72:68;
ethernet00:00:00:00:00:01;
etherneta8:7c:01:10:25:ca;
ethernet14:a3:64:9c:b9:dd;
ethernetc8:08:e9:44:70:97;
ethernet00:0a:eb:95:0e:e9;
ethernet00:27:22:8e:a7:e8;



fiz desta outra forma deu certo mas estranho q linha n fico por igual.

grep -E -A3 "ethernet|fixed-address" /etc/dhcp/dhcpd.conf | awk 'BEGIN {FS="\n";RS="\n--";} {print $1,$2,$3}'
hardware ethernet 54:9f:35:0d:0c:ae; fixed-address 192.168.30.253; }
hardware ethernet 08:00:27:81:10:58; fixed-address 192.168.30.254;
hardware ethernet 08:00:27:f7:02:af; fixed-address 192.168.30.252;
hardware ethernet 08:00:27:bf:5c:f9; fixed-address 192.168.30.251;
hardware ethernet 00:bb:46:14:4f:b9; fixed-address 192.168.30.250;
hardware ethernet 00:1d:ba:92:64:b6; fixed-address 192.168.30.30;
hardware ethernet 70:4d:7b:62:90:63; fixed-address 192.168.30.31;
hardware ethernet 48:5b:39:ce:fd:0b; fixed-address 192.168.30.40;
hardware ethernet 94:de:80:03:b0:db; fixed-address 192.168.30.42;
hardware ethernet 50:e5:49:f3:9c:1f; fixed-address 192.168.30.43;
hardware ethernet 4c:ed:de:c5:1e:7f; fixed-address 192.168.30.44;
hardware ethernet e0:b9:a5:0c:3c:d6; fixed-address 192.168.30.53;
hardware ethernet 6c:62:6d:30:b0:df; fixed-address 192.168.30.54;
hardware ethernet 44:6d:57:33:74:5d; fixed-address 192.168.30.55;
hardware ethernet ac:16:2d:34:72:68; fixed-address 192.168.30.56;
hardware ethernet 00:00:00:00:00:01; fixed-address 192.168.30.57;
hardware ethernet a8:7c:01:10:25:ca; fixed-address 192.168.30.60;
hardware ethernet 14:a3:64:9c:b9:dd; fixed-address 192.168.30.61;
hardware ethernet c8:08:e9:44:70:97; fixed-address 192.168.30.79;
hardware ethernet 00:0a:eb:95:0e:e9; fixed-address 192.168.30.70;
hardware ethernet 00:27:22:8e:a7:e8; fixed-address 192.168.30.71;



Lucas, boa tarde.
A Intenção do comando "grep" é "fazer um arquivo padrão".
Copiei e colei o "/etc/dhcp/dhclient.conf" que vc postou . . . .
Com o comando:
grep -E -A1 'hardware ethernet' /etc/dhcp/dhclient.conf|sed 's/^--$//' 
#PEGUE a linha que tem a string "'hardware ethernet", mostre a linha abaixo e troque "--" por "NADA"

OBTENHO:
hardware ethernet 00:bb:46:14:4f:b9;
fixed-address 192.168.3.250;


hardware ethernet 00:1d:ba:92:64:b6;
fixed-address 192.168.3.30;


hardware ethernet 78:24:af:78:3c:c6;
fixed-address 192.168.3.31;

Direcionando para o awk, "pego" somente os IP's e os MAC's.
grep -E -A1 'hardware ethernet' CONF.txt|sed 's/^--$//'|awk 'BEGIN{FS=" "; RS="\n\n";} {print $3,$5}'
#awk 'BEGIN{FS=" "; RS="\n\n";} {print $3,$5}' => Indico que o SEPARADOR de CAMPO é o " ", e o SEPARADOR de REGISTRO são DUAS LINHAS , printo os campos 3 e 5.
É Isso.

Att.:
Marcelo Oliver

3. Re: Busca de lista

Ryuk Shinigami
Ryuk

(usa Nenhuma)

Enviado em 19/09/2017 - 21:44h

grep -E "ethernet|address" /etc/dhcp/dhcpd.conf | tr -d '\n' 



4. Re: Busca de lista [RESOLVIDO]

Marcelo Oliver
msoliver

(usa Debian)

Enviado em 19/09/2017 - 21:49h

Lucas Peregrino escreveu:

Boa noite estou tentado puxar duas lista de um único arquivo individualizante consigo mas junto estou tendo problema alguem poderia me dar uma ajuda.

cat /etc/dhcp/dhcpd.conf

host Estacao {
allow client-updates;
allow unknown-clients;
hardware ethernet 00:11:23:9e:a1:e2;
fixed-address 192.168.30.71;
}

Gostaria de lista um do lado do outro se possivel. Para saber se interface ja foi cadastrada com outro ip.

hardware ethernet 00:27:22:8e:a7:e8; fixed-address 192.168.3.71;



Boa noite Lucas, segue:
awk 'BEGIN {FS="\n";RS="\n\n";} {print $4,$5}' /etc/dhcp/dhcpd.conf 


Att.:
Marcelo OLiver


5. Re: Busca de lista [RESOLVIDO]

Lucas Peregrino
Lucas Peregrino

(usa Debian)

Enviado em 21/09/2017 - 07:16h

bom dia olhei os comandos que me mandaram fico agradecido mais ainda não deu certo pelo que preciso.


se eu usar ele dessa forma. lista o mac e ip tem como separa colocar um do lado do outro ??

cat /etc/dhcp/dhcpd.conf | grep -E "ethernet|fixed-address" | awk '{print $2 $3}' | sed -e s/ethernet//g | sed -e s/fixed-address//g

192.168.30.30;
70:4a:4b:62:90:63;
192.168.30.31;
48:5c:19:ce:fd:0b;
192.168.30.40;
94:da:60:03:b0:db;
192.168.30.42;
50:e1:19:f3:9c:1f;
192.168.30.43;
4c:de:ed:c5:1e:7f;
192.168.30.44;
e0:b5:a3:0c:3c:d6;
192.168.30.53;
6c:34:6c:30:b0:df;
192.168.30.54;
44:6c:33:33:74:5d;
192.168.30.55;
ac:15:2e:34:72:68;
192.168.30.56;
00:00:00:00:00:01;
192.168.30.57;
a8:6c:11:10:25:ca;
192.168.30.60;
14:ac:44:9c:b9:dd;
192.168.30.61;
c8:06:b9:44:70:97;
192.168.30.79;
00:1a:ab:95:0e:e9;
192.168.30.70;

ja seu eu usei esse ele não lista todas as configurações não so a primeira linha.

cat /etc/dhcp/dhcpd.conf | grep -E "ethernet|fixed-address" | awk 'BEGIN {FS="\n";RS="\n\n";} {print $2 $3}'

fixed-address 192.168.30.253; hardware ethernet 00:00:17:41:00:18;



6. Re: Busca de lista [RESOLVIDO]

Ryuk Shinigami
Ryuk

(usa Nenhuma)

Enviado em 21/09/2017 - 10:30h

O comando do Marcelo funciona perfeitamente, você é que usou de outra forma... use como foi recomendado!

$ awk 'BEGIN {FS="\n";RS="\n\n";} {print $4,$5}' arquivo 
hardware ethernet 00:11:23:9e:a1:e2; fixed-address 192.168.30.71;
hardware ethernet 00:11:23:9e:a1:e3; fixed-address 192.168.30.72;
hardware ethernet 00:11:23:9e:a1:e4; fixed-address 192.168.30.73;
hardware ethernet 00:11:23:9e:a1:e5; fixed-address 192.168.30.74;

ou
$ awk 'BEGIN {FS="\n";RS="\n\n";} {print $4,$5}' arquivo | cut -d" " -f3,5
00:11:23:9e:a1:e2; 192.168.30.71;
00:11:23:9e:a1:e3; 192.168.30.72;
00:11:23:9e:a1:e4; 192.168.30.73;
00:11:23:9e:a1:e5; 192.168.30.74;





7. Re: Busca de lista [RESOLVIDO]

Marcelo Oliver
msoliver

(usa Debian)

Enviado em 21/09/2017 - 11:56h

Lucas Peregrino escreveu:

bom dia olhei os comandos que me mandaram fico agradecido mais ainda não deu certo pelo que preciso.


se eu usar ele dessa forma. lista o mac e ip tem como separa colocar um do lado do outro ??

cat /etc/dhcp/dhcpd.conf | grep -E "ethernet|fixed-address" | awk '{print $2 $3}' | sed -e s/ethernet//g | sed -e s/fixed-address//g

192.168.30.30;
70:4a:4b:62:90:63;
192.168.30.31;
48:5c:19:ce:fd:0b;
192.168.30.40;
94:da:60:03:b0:db;
192.168.30.42;
50:e1:19:f3:9c:1f;
192.168.30.43;
4c:de:ed:c5:1e:7f;
192.168.30.44;
e0:b5:a3:0c:3c:d6;
192.168.30.53;
6c:34:6c:30:b0:df;
192.168.30.54;
44:6c:33:33:74:5d;
192.168.30.55;
ac:15:2e:34:72:68;
192.168.30.56;
00:00:00:00:00:01;
192.168.30.57;
a8:6c:11:10:25:ca;
192.168.30.60;
14:ac:44:9c:b9:dd;
192.168.30.61;
c8:06:b9:44:70:97;
192.168.30.79;
00:1a:ab:95:0e:e9;
192.168.30.70;

ja seu eu usei esse ele não lista todas as configurações não so a primeira linha.

cat /etc/dhcp/dhcpd.conf | grep -E "ethernet|fixed-address" | awk 'BEGIN {FS="\n";RS="\n\n";} {print $2 $3}'

fixed-address 192.168.30.253; hardware ethernet 00:00:17:41:00:18;


Boa tarde Lucas.
Segue outra opção para lista somente o MAC e o IP:
awk -F '[" ""\n"]' 'BEGIN{RS="\n\n";} {print $10,$12}' ARQUIVO.txt
00:11:23:9e:a1:e2; 192.168.30.71;
00:11:23:9e:a1:e2; 192.168.30.72;
00:11:23:9e:a1:e2; 192.168.30.73;
00:11:23:9e:a1:e2; 192.168.30.74;
00:11:23:9e:a1:e2; 192.168.30.75;


cat ARQUIVO.txt
host Estacao {
allow client-updates;
allow unknown-clients;
hardware ethernet 00:11:23:9e:a1:e2;
fixed-address 192.168.30.71;
}

host Estacao {
allow client-updates;
allow unknown-clients;
hardware ethernet 00:11:23:9e:a1:e2;
fixed-address 192.168.30.72;
}

host Estacao {
allow client-updates;
allow unknown-clients;
hardware ethernet 00:11:23:9e:a1:e2;
fixed-address 192.168.30.73;
}

host Estacao {
allow client-updates;
allow unknown-clients;
hardware ethernet 00:11:23:9e:a1:e2;
fixed-address 192.168.30.74;
}

host Estacao {
allow client-updates;
allow unknown-clients;
hardware ethernet 00:11:23:9e:a1:e2;
fixed-address 192.168.30.75;
}


Poste o seu arquivo /etc/dhcp/dhcpd.conf
para chegarmos na SOLUÇãO.

Att.:
Marcelo Oliver



8. Re: Busca de lista [RESOLVIDO]

Lucas Peregrino
Lucas Peregrino

(usa Debian)

Enviado em 22/09/2017 - 10:18h

Problema que esse meu conf do dhcpd.conf mas quando posto aqui ele tira a tabulação e nao esta dando certo.

#inicio
ddns-update-style none;
default-lease-time 1800;
max-lease-time 7200;
authoritative;

shared-network eth0 {

subnet 192.168.3.0 netmask 255.255.255.0 {
range 192.168.3.100 192.168.3.150;
option routers 192.168.3.254;
option domain-name-servers 192.168.3.253,192.168.3.254;
option domain-name "Servidor";
option broadcast-address 192.168.3.255;



# Camera
host Camera {
allow client-updates;
allow unknown-clients;
hardware ethernet 00:bb:46:14:4f:b9;
fixed-address 192.168.3.250;
}

##########Faixa da Assistencia: 30-39 #########

# Sony
host Sony-R {
allow client-updates;
allow unknown-clients;
hardware ethernet 00:1d:ba:92:64:b6;
fixed-address 192.168.3.30;
}
# Clone
host Clone {
allow client-updates;
allow unknown-clients;
hardware ethernet 78:24:af:78:3c:c6;
fixed-address 192.168.3.31;
}

}
}




9. Re: Busca de lista [RESOLVIDO]

Marcelo Oliver
msoliver

(usa Debian)

Enviado em 22/09/2017 - 13:11h

Lucas Peregrino escreveu:

Problema que esse meu conf do dhcpd.conf mas quando posto aqui ele tira a tabulação e nao esta dando certo.

#inicio
ddns-update-style none;
default-lease-time 1800;
max-lease-time 7200;
authoritative;

shared-network eth0 {

subnet 192.168.3.0 netmask 255.255.255.0 {
range 192.168.3.100 192.168.3.150;
option routers 192.168.3.254;
option domain-name-servers 192.168.3.253,192.168.3.254;
option domain-name "Servidor";
option broadcast-address 192.168.3.255;



# Camera
host Camera {
allow client-updates;
allow unknown-clients;
hardware ethernet 00:bb:46:14:4f:b9;
fixed-address 192.168.3.250;
}

##########Faixa da Assistencia: 30-39 #########

# Sony
host Sony-R {
allow client-updates;
allow unknown-clients;
hardware ethernet 00:1d:ba:92:64:b6;
fixed-address 192.168.3.30;
}
# Clone
host Clone {
allow client-updates;
allow unknown-clients;
hardware ethernet 78:24:af:78:3c:c6;
fixed-address 192.168.3.31;
}

}
}



Boa tarde Lucas.
Verifique se "funciona":
grep -E -A3 'clients;$' conf.txt |awk -F '[" " "\n"]' 'BEGIN{RS="--\n";} {print $5,$7}'
00:bb:46:14:4f:b9; 192.168.3.250;
00:1d:ba:92:64:b6; 192.168.3.30;
78:24:af:78:3c:c6; 192.168.3.31;

Marcelo Oliver


10. Re: Busca de lista

Lucas Peregrino
Lucas Peregrino

(usa Debian)

Enviado em 23/09/2017 - 09:28h

grep -E -A3 'clients;$' /etc/dhcp/dhcpd.conf |awk -F '[" " "\n"]' 'BEGIN{RS="--\n";} {print $26 $27}'unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;
unknown-clients;


grep -E -A3 'ethernet|fixed-address;$' /etc/dhcp/dhcpd.conf | awk -F '[" " "\n"]' 'BEGIN {RS="--\n";} {print $26 $27}'
ethernet54:9f:35:0d:0c:ae;
ethernet08:00:27:81:10:58;
ethernet08:00:27:f7:02:af;
ethernet08:00:27:bf:5c:f9;
ethernet00:bb:46:14:4f:b9;
ethernet00:1d:ba:92:64:b6;
ethernet70:4d:7b:62:90:63;
ethernet48:5b:39:ce:fd:0b;
ethernet94:de:80:03:b0:db;
ethernet50:e5:49:f3:9c:1f;
ethernet4c:ed:de:c5:1e:7f;
ethernete0:b9:a5:0c:3c:d6;
ethernet6c:62:6d:30:b0:df;
ethernet44:6d:57:33:74:5d;
ethernetac:16:2d:34:72:68;
ethernet00:00:00:00:00:01;
etherneta8:7c:01:10:25:ca;
ethernet14:a3:64:9c:b9:dd;
ethernetc8:08:e9:44:70:97;
ethernet00:0a:eb:95:0e:e9;
ethernet00:27:22:8e:a7:e8;



fiz desta outra forma deu certo mas estranho q linha n fico por igual.

grep -E -A3 "ethernet|fixed-address" /etc/dhcp/dhcpd.conf | awk 'BEGIN {FS="\n";RS="\n--";} {print $1,$2,$3}'
hardware ethernet 54:9f:35:0d:0c:ae; fixed-address 192.168.30.253; }
hardware ethernet 08:00:27:81:10:58; fixed-address 192.168.30.254;
hardware ethernet 08:00:27:f7:02:af; fixed-address 192.168.30.252;
hardware ethernet 08:00:27:bf:5c:f9; fixed-address 192.168.30.251;
hardware ethernet 00:bb:46:14:4f:b9; fixed-address 192.168.30.250;
hardware ethernet 00:1d:ba:92:64:b6; fixed-address 192.168.30.30;
hardware ethernet 70:4d:7b:62:90:63; fixed-address 192.168.30.31;
hardware ethernet 48:5b:39:ce:fd:0b; fixed-address 192.168.30.40;
hardware ethernet 94:de:80:03:b0:db; fixed-address 192.168.30.42;
hardware ethernet 50:e5:49:f3:9c:1f; fixed-address 192.168.30.43;
hardware ethernet 4c:ed:de:c5:1e:7f; fixed-address 192.168.30.44;
hardware ethernet e0:b9:a5:0c:3c:d6; fixed-address 192.168.30.53;
hardware ethernet 6c:62:6d:30:b0:df; fixed-address 192.168.30.54;
hardware ethernet 44:6d:57:33:74:5d; fixed-address 192.168.30.55;
hardware ethernet ac:16:2d:34:72:68; fixed-address 192.168.30.56;
hardware ethernet 00:00:00:00:00:01; fixed-address 192.168.30.57;
hardware ethernet a8:7c:01:10:25:ca; fixed-address 192.168.30.60;
hardware ethernet 14:a3:64:9c:b9:dd; fixed-address 192.168.30.61;
hardware ethernet c8:08:e9:44:70:97; fixed-address 192.168.30.79;
hardware ethernet 00:0a:eb:95:0e:e9; fixed-address 192.168.30.70;
hardware ethernet 00:27:22:8e:a7:e8; fixed-address 192.168.30.71;








Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts