기본 콘텐츠로 건너뛰기

네트워크 상의 IP 주소로 MAC 주소를 추출하는 방법


Subject :  How can I get a list of MAC to IP addresses on the network?



An easy way to get a list of MAC to IP addresses on the local subnet is to ping every host on the subnet and then check you ARP cache, however pinging every individual node would take ages and the entries only stay in the ARP cache for 2 minutes.
로컬 서브넷 상의 IP 주소에 대한 MAC 주소 목록을 획득하는 쉬운 방법은 서브넷 상의 모든 호스트에게 Ping 을 하고 ARP(Address Resolution Protocol) 캐쉬를 확인하는 것이다. 그러나, 모든 개별 노드에 Ping 하는 것은 많은 시간이 걸릴 것이고 2분동안만 ARP 캐쉬에 체재하면서 들어갈 수 있다.
(참고) ARP 캐쉬는 Linux 의 경우 20분, Windows Server 의 경우 2분이 기본적인 Life Time  이다. 그 이후에는 그 데이타가 지워진다.


An alternative is to ping the broadcast mask of your subnet which will ping every host on the local subnet (you can't ping the entire network as you only communicate directly with nodes on the same subnet, all other requests are via the gateway so you would just get a ARP entry for the gateway).
로컬 서브넷상의 모든 호스트를 Ping 하게 될 사용자의 서브넷 브로드캐스트 마스크를 Ping 하는 것이 또 다른 방법이다.(동일 서브넷 상의 노드와 직접적으로 통신하는 것만으로 전체 네트워크를 Ping 할 수 없다. 다른 모든 요청은 게이트웨이를 경유하므로 사용자는 게이트웨이에 대한 ARP 내용을 얻을 수 있다.)

What is the broadcast mask? The broadcast mask is easy to calculate if the subnet mask is in the format 255.255.255.0 or 255.255.0.0 etc. (multiples of 8 bits).
그럼, 브로트캐스트 마스란 무엇인가? 브로드캐스트 마스크는 만일 서브넷 마스크가 255.255.255.0 형식이거나 255.255.0.0 등과 같이 (8비트의 배수) 형식이라면 쉽게 계산된다.

For example if the IP address was 134.189.23.42 and the subnet mask was 255.255.0.0 the broadcast mask would be 134.189.255.255, where 255 is in the subnet mask the number from the IP address is copied over, where 0 it is replaced with 255, basically the network id part is kept. If the subnet mask is not the basic 255.255 format, you should use the following, all you need is the IP address and the subnet mask
예를들어 IP 주소가 134.189.23.42 이고 서브넷 마스크값이 255.255.0.0 이라면 브로드캐스트 마스크는 134.189.255.255 가 될 것이다. 여기서 서브넷 마스크의 255는 IP 주소로 덮어써지는 숫자이며 0은 255로 대채되는 숫자이다. 기본적으로 네트워크 ID 부분은 유지된다. 만일 서브넷 마스크가 기본적인 255.255 형식이 아니라면, 사용자는 다음의 내용을 사용해 보라. 사용자에게 필요한 것은 IP 주소와 서브넷 마스크이다.
  1. For each bit set to 1 in the subnet mask, copy the corresponding but from the IP address to the broadcast mask
    서브넷 마스크의 1로 설정된 각각의 비트에 대해 해당하는 IP 주소가 브로드캐스트 마스크로 복사된다.
  2. For each bit set to 0 in the subnet mask, copy a 1 into the corresponding bit of the broadcast mask
    서브넷 마스크의 0으로 설정된 각각의 비트에 대해 브로드캐스트 마스크의 관련 비트로 1을 복사한다. 
for example, IP address 158.234.24.98 and subnet mask 255.255.248.0
(예)IP 주소 : 158.234.24.98, 서브넷 마스크 255.255.248.0
Network
Host
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
1
1
0
1
1
1
0
1
0
1
0
0
0
0
1
1
0
0
0
0
1
1
0
0
0
1
0
1
0
0
1
1
1
1
0
1
1
1
0
1
0
1
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
Byte 1
Byte 2
Byte 3
Byte 4
The first row is the subnet mask 255.255.248.0, the second row the IP address 158.234.24.98 and the third row is the broadcast mask, 158.234.31.255.
첫번째 줄은 서브넷 마스크 255.255.248.0 이고, 두번째 줄은 IP 주소 158.234.24.98이다. 세번째 줄은 브로드캐스트 마스크인 158.234.31.255이다.

To get the MAC to IP addresses, you would therefore perform the following
IP 주소의 MAC 을 얻으려면, 아래의 내용을 따라하면 된다.

ping
arp -a

Voila, a list of IP addresses and their MAC address (you can add > filename to get the list to a file, e.g. arp -a > iptomac.lst). You could repeat this exercise on the various subnets of your organization.
IP 주소 목록과 IP 주소에 해당하는 MAC 주소의 목록을 ping, arp -a 명령으로 획득할 수 있다. 여기서, 파일로 목록을 저장하기 위해 파일 이름앞에 > 를 추가한다. (ex) arp -a > iptomac.lst).
(참고) 이를 파이프라 부르며, 명령 수행의 결과를 파이프를 통해 한 곳에 모은다고 생각하면 된다. 예전에 DOS 를 사용할 시에 상당히 많이 사용했던 것인데, 아래에 설명되고 있는 | (필터)도 마찬가지다.

Unfortunatly due to limitations in NT's implementation of PING the above will not work correctly so put the following into a file
불행히도 NT Windows 의 PING 도구의 한계로 위의 작업을 정확히 수행할 수 없을 것이다. 따라서 다음의 파일을 작성하여 작업을 수행한다.
아래 내용을 다음과 같이 작성한다.
C:\>copy con arpping.bat
REM arpping.bat
ping -n 1 -l 1 %1.%2
arp -a %1.%2

^Z
이렇게 하면 Command Shell Console 에서 파일 하나가 작성된다.( 여기서, ^Z : Ctrl + Z )

You can then call the batch file as follows:
다음과 같이 이 배치 파일을 호출한다:

C:\>for /l %i in (1,1,254) do arpping 160.82.220 %i
In this case it would generate a list of all MAC to IP addresses for 160.82.220.1 to 160.82.220.254. Again you could put this all in a file, redirect to a file and then search, e.g.
이렇게 하게 될 경우, 160.82.220.1 에서 160.82.220.254까지의 IP 주소에 해당하는 MAC 주소 목록 모두를 생성한다.
또한 사용자는 이 모든 내용을 파일로 저장할 수 있다.

C:\>copy con test.bat
REM test.bat
for /l %%i in (1,1,254) do arpping.bat 160.82.220 %%i

^Z

Notice you have to use two %%. You could run as
주의할 점은 반드시 %% 두개를 사용해야 한다는 것다. 다음과 같이 실행해 보라.

C:\>test.bat > file.txt

Then search listing.txt for (example) dynamic
아래와 같이 listing.txt 파일내에서 dynamic 이라는 문자열을 검색할 수 있다.

C:\> findstr dynamic file.txt
160.82.220.1 00-00-0c-60-8b-41 dynamic
160.82.220.9 00-60-97-4b-bf-4c dynamic
160.82.220.13 00-10-4b-49-94-e1 dynamic
160.82.220.17 00-80-5f-d8-a4-8b dynamic
160.82.220.22 00-a0-d1-02-a4-cf dynamic
160.82.220.25 00-60-08-75-0d-7a dynamic
160.82.220.26 00-10-4b-44-e4-73 dynamic
160.82.220.33 00-10-4b-44-d6-33 dynamic
160.82.220.34 00-10-4b-4e-67-6a dynamic
160.82.220.35 00-60-97-4b-c4-53 dynamic
160.82.220.39 00-10-4b-44-eb-ae dynamic
160.82.220.41 00-10-4b-49-7b-f7 dynamic
160.82.220.42 00-00-f8-21-7a-7f dynamic
160.82.220.43 08-00-20-88-82-57 dynamic
160.82.220.221 00-80-5f-88-d0-55 dynamic


You can consolidate the last couple of steps so you just create arpping.bat as before then just issue command:
사용자는 | 라는 필터를 통해 다음과 같이 반복해서 수행하는 for loop 내의 호출 뒤에 필터를 두어 연이은 명령을 수행할 수 있다. 위의 예제를 연속해서 수행하는 것과 같다.

C:\>for /l %i in (1,1,254) do arpping.bat 10.129.210 %i |findstr dynamic

C:/>arpping.bat 10.129.210 1 | findstr dynamic
10.129.210.1 00-08-c7-d3-24-f5 dynamic

C:\>arpping.bat 10.129.210 2 | findstr dynamic
10.129.210.2 00-08-c7-df-81-60 dynamic

C:\>arpping.bat 10.129.210 3 | findstr dynamic
10.129.210.3 00-80-5f-9b-ea-93 dynamic

C:\>arpping.bat 10.129.210 4 | findstr dynamic
10.129.210.4 00-80-5f-9b-36-ea dynamic

C:\>arpping.bat 10.129.210 5 | findstr dynamic
10.129.210.5 00-04-ac-37-78-92 dynamic

C:\>arpping.bat 10.129.210 6 | findstr dynamic

Notice we only use one % as we are not in a batch file and it automatically only lists found entires or you can use a combination of the different methods to match your exact needs.


원본 : http://windowsitpro.com/article/articleid/14462/how-can-i-get-a-list-of-mac-to-ip-addresses-on-the-network.html


댓글

익명님의 메시지…
블로그 관리자가 댓글을 삭제했습니다.
익명님의 메시지…
감사합니다 ^_^

이 블로그의 인기 게시물

VIDEO_DXGKRNL_FATAL_ERROR on Windows 8.1

Windows 8.1 로 업데이트 이후, Booting 시 Blue Screen 이 뜨면서, VIDEO_DXGKRNL_FATAL_ERROR 또는 SYSTEM_SERVICE_EXCEPTION (atikmpag.sys)  가 발생하는 문제점이 있을 때, 아래와 같이 조치해 보십시오. 제어판 -> 전원 옵션 -> 설정 변경 덮개를 닫으면 수행되는 작업 선택 -> 현재 사용할 수 없는 설정 변경 -> 종료 설정 -> 빠른 시작 켜기(권장)의 Check Box 를 해제함.

Ubuntu (Kubuntu) 에 desktop 파일 만들기

Package 관리자등을 통해 직접 Repository 에 있는 Application 을 설치하는 경우에는 필요한 경로와 파일, Category 로 분류된 Icon 등록 등이 자동적으로 이루어지나 firefox, eclipse 등 새로운 버전을 새로 설치할 경우, 다음과 같은 절차를 통해 시작메뉴에 등록시킬 수 있다. 다음은 eclipse-SDK-3.6-linuxx-gtk.tar.gz 을 받아 설치 등록하는 것을 예로 든다. 1. 다운받은 파일을 /usr/lib에 압축해제한다. (물론, super user 계정으로 실행해야 한다.) 2. 보통의 경우, /usr/bin Directory 는 PATH 에 물려 있으므로 다음과 같은 실행 파일을 만들어 놓는다. # cd /usr/lib # chmod +x eclipse # cd /usr/bin # sudo nano eclipse eclipse 파일에는 아래의 내용을 입력하여 넣는다. export ECLIPSE_HOME="/usr/lib/eclipse" $ECLIPSE_HOME/eclipse $ * # sudo chmod 755 eclipse 3. Desktop Menu 에 추가하려면 # cd /usr/share/applications # sudo nano eclipse.desktop [Desktop Entry] Encoding=UTF-8 Name=Eclipse Comment=Eclipse IDE Exec=eclipse Icon=/usr/lib/eclipse/icon.xpm Terminal=false Type=Application Categories=GNOME;Application;Development' StartupNotify=true 이렇게 입력한 파일을 저장하면, 시작메뉴 > 개발 > Eclipse 아이콘이 생성되어 메뉴에서 직접 실행할 수 있게된다.