Anda di halaman 1dari 6

EN3610 – Gerenciamento e interoperabilidade de redes

Prof. João Henrique Kleinschmidt


Prática – SNMP

1 – MIBs RMON

No Linux os arquivos MIB são armazenados no diretório /usr/share/snmp/mibs. Cada


arquivo MIB especifica um conjunto de objetos gerenciados.
Vá para o diretório e explore a RMON-MIB. Responda as seguintes questões:

1- Quais os grupos da RMON-MIB?

2- Descreva 6 objetos de pelo menos 3 grupos diferentes.

2 – Net-SNMP

Net-SNMP (http://www.net-snmp.org) é um conjunto de aplicações usado para


implementar SNMPv1, SNMPv2 e SNMPv3. Incluiu aplicações de linha de comando
para coletar informações, manipular configurações, receber notificações, agente SNMP
e biblioteca para desenvolver novas aplicações SNMP.

Para iniciar um agente SNMP, usamos o comando snmpd. Por padrão, aceita requisições
na porta 161 (UDP).

A sintaxe geral dos comandos de um gerente SNMP é assim: (detalhes nas mans pages)
snmpcmd [-v versão] -c comunidade agente objectid

Execute o seguinte comando (o agente deve estar sendo executado).


snmpget -v 1 -c public localhost system.sysName.0

O que faz este comando? Qual a informação retornada?

Por que é necessário o sufixo “.0”?

Como outros objetos podem ser acessados? Dê exemplos.

3 – Configuração do agente NET-SNMP:

Agente: snmpd
Arquivo:/etc/snmp/snmpd.conf
Configuração: utilitário snmpconf (alterações gravados no /etc/snmp/snmpd.conf)
dúvidas: consulte o manual on-line : man snmpd.conf

3.1 – Utilizando o snmpconf

----- Iniciando o snmpconf


-- Abra um terminal (shell) no linux e execute o comando snmpconf
-- O primeiro menu pergunta se desejamos importar as configurações dos
-- arquivos existentes. A resposta é não, logo responda com a
opção none.

The following installed configuration files were found:

1: /etc/snmp/snmpd.conf
2: /etc/snmp/snmptrapd.conf

Would you like me to read them in? Their content will be merged with
the
output files created by this session.

Valid answer examples: "all", "none","3","1,2,5"

Read in which (default = all): none

-- Apos ele irá pergunta qual o arquivo de configuração que queremos


criar. Para a configuração do agente, devemos escolher a opção
do snmpd.conf
I can create the following types of configuration files for you.
Select the file type you wish to create:
(you can create more than one as you run this program)

1: snmpd.conf
2: snmp.conf
3: snmptrapd.conf

Other options: quit

Select File: 1

-- Após devemos configurar o agente snmp.


-- A primeira opção a ser escolhida é a opção 2 para configuração de
-- informações do grupo system da MIB-II
The configuration information which can be put into snmpd.conf is
divided into sections. Select a configuration section for snmpd.conf
that you wish to create:

1: Trap Destinations
2: System Information Setup
3: Access Control Setup
4: Extending the Agent
5: Monitor Various Aspects of the Running Host
6: Agent Operating Mode

Other options: finished

Select section: 2

-- Aqui inicia a configuração da opção 2.


-- A opção 1 será para configurar o valor do objeto syslocation,
-- a opção 2 será para configurar o valor do objeto syscontact, e
-- a opção 3 será para configurar o valor do objeto sysservices
-- veja um exemplo da configuração a seguir. Observe
que sempre após a configuração da opção, volta-se ao menu para
escolher a próxima opção.

Section: System Information Setup


Description:
This section defines some of the information reported in
the "system" mib group in the mibII tree.
Select from:

1: The [typically physical] location of the system.


2: The contact information for the administrator
3: The proper value for the sysServices object.

Other options: finished, list

Select section: 1

Configuring: syslocation
Description:
The [typically physical] location of the system.
Note that setting this value here means that when trying to
perform an snmp SET operation to the sysLocation.0 variable will
make
the agent return the "notWritable" error code. IE, including
this token in the snmpd.conf file will disable write access to
the variable.
arguments: location_string

The location of the system: L502


-----------------------------------------------------------------

Section: System Information Setup


Description:
This section defines some of the information reported in
the "system" mib group in the mibII tree.

Select from:

1: The [typically physical] location of the system.


2: The contact information for the administrator
3: The proper value for the sysServices object.

Other options: finished, list

Select section: 2

Configuring: syscontact
Description:
The contact information for the administrator
Note that setting this value here means that when trying to
perform an snmp SET operation to the sysContact.0 variable will
make
the agent return the "notWritable" error code. IE, including
this token in the snmpd.conf file will disable write access to
the variable.
arguments: contact_string

The contact information: joao

-----------------------------------------------------------------
Section: System Information Setup
Description:
This section defines some of the information reported in
the "system" mib group in the mibII tree.

Select from:
1: The [typically physical] location of the system.
2: The contact information for the administrator
3: The proper value for the sysServices object.

Other options: finished, list

Select section: 3

Configuring: sysservices
Description:
The proper value for the sysServices object.
arguments: sysservices_number

does this host offer physical services (eg, like a repeater) [answer 0
or 1]:
0

does this host offer datalink/subnetwork services (eg, like a bridge):


0
does this host offer internet services (eg, supports IP): 1
does this host offer end-to-end services (eg, supports TCP): 1
does this host offer application services (eg, supports SMTP): 0

Finished Output: sysservices 12

-----------------------------------------------------------------

-- Após a configuração do sysservice, deve digitar finished até voltar


-- para o menu
-- Escolha a opção 3
The configuration information which can be put into snmpd.conf is
divided into sections. Select a configuration section for snmpd.conf
that you wish to create:

1: Trap Destinations
2: System Information Setup
3: Access Control Setup
4: Extending the Agent
5: Monitor Various Aspects of the Running Host
6: Agent Operating Mode

Other options: finished

Select section: 3

-- No menu de configuração de controle de acesso escolha a opção 4


Section: Access Control Setup
Description:
This section defines who is allowed to talk to your running
snmp agent.

Select from:

1: a SNMPv3 read-write user


2: a SNMPv3 read-only user
3: a SNMPv1/SNMPv2c read-only access community name
4: a SNMPv1/SNMPv2c read-write access community name
Other options: finished, list

Select section: 4

-- Aqui inicia a configuração da comunidade de leitura e escrita


Configuring: rwcommunity
Description:
a SNMPv1/SNMPv2c read-write access community name
arguments: community [default|hostname|network/bits] [oid]

-- Forneça o nome da comunidade


Enter the community name to add read-write access for: public

-- Digite ENTER e aceite a configuração default


The hostname or network address to accept this community name from
[RETURN for all]:

-- Digite ENTER e aceite a configuração default


The OID that this community should be restricted to [RETURN for no-
restriction]:

Finished Output: rwcommunity public

-- Após a configuração destas opções digite finished até voltar para o


primeiro menu e então escolha a opção quit:

Select the file type you wish to create:


(you can create more than one as you run this program)

1: snmpd.conf
2: snmp.conf
3: snmptrapd.conf

Other options: quit

Select File: quit

-- Então será criado o arquivo snmpd.conf que ficará gravado no


diretório no qual você executou o snmpconf

The following files were created:

snmpd.conf

These files should be moved to /usr/share/snmp if you


want them used by everyone on the system. In the future, if you add
the -i option to the command line I'll copy them there automatically
for you.

Or, if you want them for your personal use only, copy them to
/root/.snmp . In the future, if you add the -p option to the
command line I'll copy them there automatically for you.

Acesse o arquivo snmpd.conf criado e veja sua configuração. Explique as principais


configurações (diretivas com2sec, group, view, access). Veja ajuda nas man pages.
Para que as modificações nesse arquivo tenham efeito, o agente precisa ser reiniciado
(snmpd restart).
4 – Comandos do gerente SNMP

4.1 Execute o seguinte comando (o agente deve estar sendo executado).


snmpget -v 1 -c public localhost system.sysName.0

4.2 O comando snmpgetnext retorna o valor da próxima variável de acordo com a ordem
dos OIDs (retorna o próximo objeto na árvore). Execute alguns exemplos e explique
como funciona este comando.

4.3 O comando snmpwalk pode ser usado para retornar o valor de todos os objetos de
uma sub-árvore na hierarquia de objetos MIB (“walking”, ou andando pela MIB).
Explique os resultados obtidos.

snmpwalk -v 1 -c public localhost system


snmpwalk -v 1 -c public localhost interface

Anda mungkin juga menyukai