WinPcap: Packet.dll -- Packet Driver API
http://openmaniak.com/cdp.php
The Easy Tutorial - OpenManiak.com
If you like our tutorials, don't hesitate to support us and visit our sponsors!
Si vous aimez nos tutoriaux, n'hésitez pas à nous supporter et visiter nos sponsors!
The CDP protocol:
The Cisco Discovery Protocol (CDP) is a proprietary layer 2 network protocol developed by Cisco Systems.
It runs on Cisco and some HP equipment devices.
It is useful for two reasons:
The Cisco Discovery Protocol (CDP) is a proprietary layer 2 network protocol developed by Cisco Systems.
It runs on Cisco and some HP equipment devices.
It is useful for two reasons:
- - | Getting information about the directly connected CDP devices such as the operating system version and IP address. Checking that the OSI layer 2 connectivity is okay in case of IP (OSI layer 3) connectivity problems |
The CDP announcements are sent to the multicast destination address 01-00-0c-cc-cc-cc.
CDP on Linux:
Linux does not natively support the CDP protocol, so we have to use a tool called "cdp-tools" to activate it.
Enabling CDP on Linux systems can be interesting on routers like Quagga and Vyatta in a Cisco environment.
Download CDP-tools in the /root directory.
If you want to download "cdp-tools" directly from the Linux CLI, proceed as follows:
#wget http://gpl.internetconnection.net/files/cdp-tools.tar.gz |
Extract "cdp-tools":
#tar -xvf cdp-tools.tar |
This will create the "cdp-tools" directory.
Download and install the "build-essential" meta-package containing the tools to compile programs.
Download and install the "build-essential" meta-package containing the tools to compile programs.
#apt-get install build-essential |
Download and install libnet0-dev:
Libnet0 is a generic networking API that provides access to several protocols.
Libnet0 is a generic networking API that provides access to several protocols.
#apt-get install libnet0-dev |
The libpcap library (in our example libpcap0.8-dev) is installed at the same time.
Compile "cdp-tools":
Compile "cdp-tools":
#make |
cc -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H -DLIBNET_LIL_ENDIAN -c -o cdp-listen.o cdp-listen.c
cc cdp-listen.o /usr/lib/libpcap.so -o cdp-listen
cc -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H -DLIBNET_LIL_ENDIAN -c -o cdp-send.o cdp-send.c
cdp-send.c:70: warning: 'packed’ attribute ignored for field of type ‘unsigned char[6]'
cdp-send.c:71: warning: 'packed' attribute ignored for field of type 'unsigned char[6]'
cdp-send.c:74: warning: 'packed' attribute ignored for field of type 'u_int8_t'
cdp-send.c:75: warning: 'packed' attribute ignored for field of type 'u_int8_t'
cdp-send.c:77: warning: 'packed' attribute ignored for field of type 'u_int8_t'
cdp-send.c:78: warning: 'packed' attribute ignored for field of type 'u_int8_t[3]'
cc cdp-send.o /usr/lib/libnet.so -o cdp-send
If everything goes as planned, you should have two new files called "cdp-send" and "cdp-listen" which are used to respectively send or receive traffic.
cc cdp-listen.o /usr/lib/libpcap.so -o cdp-listen
cc -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H -DLIBNET_LIL_ENDIAN -c -o cdp-send.o cdp-send.c
cdp-send.c:70: warning: 'packed’ attribute ignored for field of type ‘unsigned char[6]'
cdp-send.c:71: warning: 'packed' attribute ignored for field of type 'unsigned char[6]'
cdp-send.c:74: warning: 'packed' attribute ignored for field of type 'u_int8_t'
cdp-send.c:75: warning: 'packed' attribute ignored for field of type 'u_int8_t'
cdp-send.c:77: warning: 'packed' attribute ignored for field of type 'u_int8_t'
cdp-send.c:78: warning: 'packed' attribute ignored for field of type 'u_int8_t[3]'
cc cdp-send.o /usr/lib/libnet.so -o cdp-send
If everything goes as planned, you should have two new files called "cdp-send" and "cdp-listen" which are used to respectively send or receive traffic.
/root/cdp-tools/cdp-send eth0 |
Cisco_device>show cdp neighbours |
Capability Codes: | R - Router, T - Trans Bridge, B - Source Route Bridge | ||||
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone | |||||
Device ID | Local Intrfce | Holdtme |
Capability
| Platform | Port ID |
ubuntu | Fas 1/0/5 | 176 |
H
| i686 | eth0 |
Cisco_device>show cdp neighbours details |
Device ID: ubuntu Entry address(es): IP address: 10.1.1.1 Platform: i686, Capabilities: Host Interface: FastEthernet1/0/5, Port ID (outgoing port): eth0 Holdtime : 120 sec Version : Linux 2.6.22-10-generic advertisement version: 2 Management address(es): |
#crontab -u root -e |
@reboot /root/cdp-send eth0 |
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。