Debian Codegraph @

README.md

raw symbols SCIP
1 # ARP Ping
2
3 By Thomas Habets <[email protected]>
4
5 * <http://www.habets.pp.se/synscan/>
6 * <http://github.com/ThomasHabets/arping>
7 * `git clone https://github.com/ThomasHabets/arping.git`
8
9 ## Introduction
10
11 Arping is a util to find out if a specific IP address on the LAN is 'taken'
12 and what MAC address owns it. Sure, you *could* just use 'ping' to find out if
13 it's taken and even if the computer blocks ping (and everything else) you still
14 get an entry in your ARP cache. But what if you aren't on a routable net? Or
15 the host blocks ping (all ICMP even)? Then you're screwed. Or you use arping.
16
17 ## Why it's not stupid
18
19 Say you have a block of N real IANA-assigned IP-addresses. You want to debug
20 the net and you don't know which IP addresses are taken. You can't ping anyone
21 before you take the IP, and you can't pick an IP before you know which are
22 already taken. Catch 22. But with arping you can 'ping' the IP and if you get
23 no response, the IP is available.
24
25 ## Example uses
26
27 If some box is dumping non-IP (like IPX) garbage and you don't know which box
28 it is, you can ping by MAC to get the IP and fix the problem.
29
30 If you are on someone else's net and want to 'borrow' a real IP address instead
31 of using one of those 10.x.x.x-addresses the DHCP hands out you probably want
32 to know which ones are taken, or people will get mad (a friend of mine got a
33 call on his cellphone about 15 seconds after he accidentally 'stole' an IP,
34 oops).
35
36 ## Compiling / installing
37
38 See INSTALL file.
39
40 I try to test arping on these platforms before any release:
41 * Latest Debian stable x86 and amd64
42 * Linux (Debian or Ubuntu) on arm
43 * Latest OpenBSD x86 or amd64
44
45 Systems that it should still work on, but I don't personally regularly test:
46 * Debian Alpha
47 * FreeBSD
48 * IRIX 6.5 mips (last test 2009-09-27)
49 * MacOS X
50 * NetBSD
51 * OpenBSD sparc64 (last test: 2009-10-02)
52 * Solaris
53
54 ## Contributing
55
56 Please run `make check` and `sudo ./tests/run` before creating a PR.
57
58 ## Mailing list
59
60 <https://groups.google.com/g/synscan>
61
62 ## How it does it
63
64 See 'Technical' at the bottom of this file.
65
66 ## FAQ
67
68 ### Q: Where is Arping 1.x? I use libnet 1.0.x so I need that!
69
70 Arping 1 has finally been removed from the Arping 2.x tarball in 2.09.
71 Arping 1.x currently only lives in the Arping packages 2.08 and lower. If
72 features are to be added or bugs fixed it will show up again as a separate
73 package forked from Arping 2.08.
74
75 For now just get arping-2.08.tar.gz and use that.
76
77 ### Q: Where's the Windows version? A compiled .exe would be nice.
78
79 I don't have a windows box, so the .exe I'm providing was NOT compiled
80 by me. If something is strange about it tell me, but there won't be much
81 I can do about it.
82 That being said:
83
84 <http://www.habets.pp.se/synscan/files/arping-for-windows-not-compiled-by-me.exe>
85
86 ### Q: After compiling arping without any problem, i test it first with localhost... but it doesn't respond. Isn't that strange?
87
88 Not really, as you can see by typing 'ifconfig' the lo (local) interface
89 does not have a MAC address. It's not a physical device! MAC addresses are
90 there to differentiate computers on a shared medium (the aether, or ether)
91 and since packets to localhost does not go over any wire there is no need
92 to identify which box is talking to which. There is only one.
93
94 ### Q: Arping can't ping anything!
95
96 Check which interface is active with `-v`. If it's the wrong one, use `-i`
97 to set it right.
98
99 ### Q: Arping finds some hosts, but not others. why? BTW, I have several NICs.
100
101 You have to choose interface with the `-i` switch if the default is wrong for
102 you.
103
104 ### Q: I tried to ping my own MAC address, but it doesn't work.
105
106 A sane OS will think it's suspicious if you send packets to yourself over
107 the wire and will ignore them.
108
109 And why would you want to lookup the IP or MAC of yourself? ifconfig
110 can tell you that.
111
112 ### Q: I can't ping any/some MAC address on my LAN.
113
114 Arping when pinging a MAC relies on the host to answer a broadcast ping
115 (icmp echo request) properly (IIRC: not the windows way). If you want a
116 host to pop up on MAC ping, you have to config it to respond to broadcast
117 pings.
118 (for linux, make sure `/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts` is 0)
119
120 or
121
122 -T <IP/host> allows you to restrict the arping to a limited subnet, which
123 may or may not work for you. For example if the box 00:01:02:03:04:05 is on
124 192.168.0.0/24 then the broadcast probably is 192.168.0.255, so try:
125
126 ```
127 # arping -T 192.168.0.255 00:01:02:03:04:05
128 ```
129
130 ### Q: ./configure says I need libnet and/or libpcap
131
132 Arping depends on libnet 1.1 or newer, and libpcap. Get libnet from
133 <https://github.com/libnet/libnet> and libpcap from <http://www.tcpdump.org>.
134 Or more likely they were both included in your Linux distribution.
135
136 The original libnet site
137 was <http://packetfactory.openwall.net/projects/libnet/>, but is not updated.
138
139 ### Q: I get `libnet_get_ipaddr(): no error` when I run arping with IP (src or dst) 255.255.255.255.
140
141 Use the `-b`/`-B` switches. Libnet sucks (ha ha only serious) and returns -1 for
142 error == int32 encoded 255.255.255.255.
143
144 ### Q: I used to be able to use `-S 255.255.255.255`, now it fails. What's going on? (or: Why can't I arping 255.255.255.255?)
145
146 Argh! Why would you want to? Anyway, this one is due to libnets resolving,
147 and my unwillingness to reimplement it (in a portable manner, ugh).
148
149 `-S 255.255.255.255` can be replaced with `-b`, and pinging broadcast (why you
150 would do that eludes me) `-B`.
151
152 To be extra perverted, try: `./arping -b -B`
153
154 ### Q: The roundtrip times are off, sometimes by milliseconds!
155
156 I know.
157
158 #### Short answer
159
160 'ping' does the same thing. (ping from iputils-ss010824 anyway)
161
162 #### Long answer
163
164 I can't (portably anyway) do anything other than queue a packet
165 to the network. That means I don't know exactly when it arrived. Also,
166 I can't tell when a packet arrives on the wire, only when arping gets
167 it from the kernel. Just make sure neither the network (whole segment
168 if you are hubbed, just your NIC if you are switched) nor your box is
169 loaded when you care about timing, and/or run arping with higher
170 priority.
171
172 ```
173 nice -n -15 arping 1.2.3.4
174 schedtool -R -p 1 -e arping 1.2.3.4
175 ```
176
177 But if you find way to get more exact timing portably (or just for one
178 OS really), let me know.
179
180 ### Q: Is it OK to make arping suid root?
181
182 Be my guest, but I'd recommend restricting execution of arping to trusted users.
183 Arping tries to drop all possible privileges as early as possible, but this is a
184 network debugging tool, which generates low-level network packets that ordinary
185 users have absolutely no business generating.
186
187 If you are honestly debugging the network then I don't see why you aren't
188 root already.
189
190 That being said, on Linux you can add the `CAP_NET_RAW` capability to arping
191 limiting the damage if arping were to be compromised:
192
193 ```
194 sudo setcap cap_net_raw+ep /usr/local/sbin/arping
195 ```
196
197 This requires a libnet 1.1.5 or higher, which does not explicitly check for
198 uid 0.
199
200 For older versions of Libnet you can try applying this patch:
201 <http://github.com/ThomasHabets/libnet/commit/aaa383b5c816107082508b7646929a9479b81645>
202
203 ### Q: What's this -A switch all about, I don't understand it.
204
205 Normally arping packets are sent out to some kind of broadcast (MAC or IPv4
206 broadcast) and hosts reply with source address == their address.
207
208 If `-A` is given, only packets coming in with a *source* address equal
209 to the *destination* address in the query is accepted.
210
211 If you don't understand, don't worry. You won't need it. But for an
212 example use, see the arping-scan-net.sh script.
213
214 ## License
215
216 It's GPLv2, see the LICENSE file.
217
218 ## Technical
219
220 Yes, I've finally bothered to write how it works.
221 tcpdumps were taken with `tcpdump -vven 'arp or icmp'`.
222
223 The source box is 192.168.0.2/0:10:5a:3e:c5:b4 and the target box is
224 192.168.0.1/0:60:93:34:91:99.
225
226 ### For pinging IP addresses
227
228 When a host wants to send an IP packet to another host, it sends out an ARP
229 packet asking what MAC the destination IP address has, a so-called 'who-has'
230 packet. This is then answered by another ARP packet, the 'is-at' packet.
231
232 ```
233 18:16:07.179699 0:10:5a:3e:c5:b4 ff:ff:ff:ff:ff:ff 0806 42:
234 arp who-has 192.168.0.1 tell 192.168.0.2
235 ```
236
237 This is the packet generated by arping.
238 An Ethernet frame from my 3com card to the broadcast address carrying an arp
239 packet asking what MAC 192.168.0.1 has (who-has).
240
241 ```
242 18:16:07.180221 0:60:93:34:91:99 0:10:5a:3e:c5:b4 0806 60:
243 arp reply 192.168.0.1 is-at 0:60:93:34:91:99
244 ```
245
246 The answer, that 192.168.0.1 has MAC 0:60:93:34:91:99 (is-at).
247
248 ### For pinging MAC addresses
249
250 A broadcast ping (255.255.255.255, or any address supplied with `-T`, see below)
251 is sent out on the Ethernet, but in an Ethernet frame addressed to the target
252 MAC only.
253
254 ```
255 18:20:09.627321 0:10:5a:3e:c5:b4 0:60:93:34:91:99 0800 42:
256 192.168.0.2 > 255.255.255.255: icmp: echo request
257 (ttl 48, id 17767, len 28)
258 ```
259
260 This is the packet generated by arping.
261 Ethernet frame from my 3com NIC to the destination MAC, carrying a broadcast
262 ping.
263
264 ```
265 18:20:09.628432 0:60:93:34:91:99 0:10:5a:3e:c5:b4 0800 60:
266 192.168.0.1 > 192.168.0.2: icmp: echo reply
267 (ttl 255, id 7593, len 28)
268 ```
269
270 The answer, including the source address of the target host. Note that this
271 is not how every OS responds to a broadcast ping (if at all). Some answer with
272 a source address equal to the broadcast address, and others don't' answer at
273 all.
274
275 This is why pinging a raw MAC doesn't always work, and you may need to play
276 with -T to get it to answer correctly (or at all). You can always brute-force
277 if you can't even find a broadcast that the box will answer correctly to.
278
279 ```
280 for d in $(seq 0 255); do
281 sudo arping -q -c 1 -T $a.$b.$c.$d 0:60:93:34:91:99
282 if [ $? = 0 ]; then
283 echo "Got answer with address: 192.168.0.$d"
284 fi
285 done
286 ```
287
288 Note that this script will take 1 second per IP since that is how long arping
289 waits, so scanning a C-class net will take 256 seconds. If you have a bigger
290 net, then write a program that will run several arpings at the same time to
291 go through more in less time, or check out arping-scan-net.sh, which is a
292 more capable script for scanning, but you need to edit it since the address
293 range it searches is hard-coded.
294
295 I may add this to arping some day, but don't hold your breath.
296
297 -----------------------------------------------------------------------
298 Send questions/suggestions/patches/rants/money/envy to [email protected]