Linux remote mac address

Resolving MAC Address from IP Address in Linux

I need to write a bash script wherein I have to create a file which holds the details of IP Addresses of the hosts and their mapping with corresponding MAC Addresses. Is there any possible way with which I can find out the MAC address of any (remote) host when IP address of the host is available?

5 Answers 5

If you just want to find out the MAC address of a given IP address you can use the command arp to look it up, once you’ve pinged the system 1 time.

Example

$ ping skinner -c 1 PING skinner.bubba.net (192.168.1.3) 56(84) bytes of data. 64 bytes from skinner.bubba.net (192.168.1.3): icmp_seq=1 ttl=64 time=3.09 ms --- skinner.bubba.net ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 3.097/3.097/3.097/0.000 ms 

Now look up in the ARP table:

$ arp -a skinner.bubba.net (192.168.1.3) at 00:19:d1:e8:4c:95 [ether] on wlp3s0 

fing

If you want to sweep the entire LAN for MAC addresses you can use the command line tool fing to do so. It’s typically not installed so you’ll have to go download it and install it manually.

fing example

Using ip

If you find you don’t have the arp or fing commands available, you could use iproute2’s command ip neigh to see your system’s ARP table instead:

$ ip neigh 192.168.1.61 dev eth0 lladdr b8:27:eb:87:74:11 REACHABLE 192.168.1.70 dev eth0 lladdr 30:b5:c2:3d:6c:37 STALE 192.168.1.95 dev eth0 lladdr f0:18:98:1d:26:e2 REACHABLE 192.168.1.2 dev eth0 lladdr 14:cc:20:d4:56:2a STALE 192.168.1.10 dev eth0 lladdr 00:22:15:91:c1:2d REACHABLE 

References

I know this is an old answer, but do you have any insight as to how Fing is implemented? I am trying to learn about this layer of networking and the tools to monitor it.

The ip neigh works most of the times without having to install extra packages. Therefore I think that’s the best answer.

But you can only use this command in LAN, if you want to find out the MAC address of any remote host, maybe you must use some tool to capture the packet like tcpdump and parsing the result.

tcpdump(8) will only show you the local MACs (i.e., the MAC of the last leg router). The MAC layer headers of input packets are stripped out by the router, and new ones added to the outgoing packet.

This is from my question and answer in Ask Ubuntu.

sudo nmap -sP -PE -PA21,23,80,3389 192.168.1.* 

nmap : Network exploration tool and security / port scanner. From the manual:

-sP (Skip port scan): This option tells Nmap not to do a port scan after host discovery, and only print out the available hosts that responded to the scan. This is often known as a “ping scan”, but you can also request that traceroute and NSE host scripts be run. This is by default one step more intrusive than the list scan, and can often be used for the same purposes. It allows light reconnaissance of a target network without attracting much attention. Knowing how many hosts are up is more valuable to attackers than the list provided by list scan of every single IP and host name.

-PE; -PP; -PM (ICMP Ping Types) : In addition to the unusual TCP, UDP and SCTP host discovery types discussed previously, Nmap can send the standard packets sent by the ubiquitous ping program. Nmap sends an ICMP type 8 (echo request) packet to the target IP addresses, expecting a type 0 (echo reply) in return from available hosts.. Unfortunately for network explorers, many hosts and firewalls now block these packets, rather than responding as required by RFC 1122[2]. For this reason, ICMP-only scans are rarely reliable enough against unknown targets over the Internet. But for system administrators monitoring an internal network, they can be a practical and efficient approach. Use the -PE option to enable this echo request behavior.

-PA port list (TCP ACK Ping) : The TCP ACK ping is quite similar to the just-discussed SYN ping. The difference, as you could likely guess, is that the TCP ACK flag is set instead of the SYN flag. Such an ACK packet purports to be acknowledging data over an established TCP connection, but no such connection exists. So remote hosts should always respond with a RST packet, disclosing their existence in the process. The -PA option uses the same default port as the SYN probe (80) and can also take a list of destination ports in the same format. If an unprivileged user tries this, the connect workaround discussed previously is used. This workaround is imperfect because connect is actually sending a SYN packet rather than an ACK.

21,23,80,3389 : Ports to search through.

Читайте также:  How to check if installed linux

192.168.1.* : Range of IPs. replace with yours.

Источник

Getting the MAC address of a remote host? Linux, macOS, Linux [closed]

Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow.

I am writing a custom application in Go. My app needs to work on Linux, macOS, and Windows 10+. I need to verify that a remote host is what I think it is. I’ve tried arping and as expected, it does not cross routers. Is there any other way to get a remote host’s MAC address if it is not on the local plan? I know ARP does not cross routers. But I am hoping that the information is somehow given as an artifact of some other kind of communication. Ideas?

1 Answer 1

The MAC address is a purely layer 2 (link layer) property. It is stripped when a packet is passed to layer 3 (network layer). This is the underlying reason why ARP does not work across routers. In order to get a MAC address from a network segment you are not directly connected to, you need the cooperation of a node which is directly connected to it. Possibilities:

a) The remote host itself whose MAC address you want to retrieve. You could simply ask it, but of course it may lie, so that’s hardly useful if your goal is to unmask an impostor. It may also inadvertently expose it, for example by using it as the host part of its IPv6 address or otherwise including it in its layer 3 traffic, but you cannot rely on that, either.

Читайте также:  Softmaker office key linux

b) The router forwarding packets from that network segment to you. It certainly sees the MAC address, and if you have administrative or SNMP access to it you may query it for that information.

c) Some other host on that network segment you can control, and from which you can issue an ARP request for the IP address of the host under investigation.

That said, checking the MAC address is not a reliable way to verify your peer’s identity, anyway, since MAC addresses are easily forged. Depending on your needs, you may want to consider better, well-established and reliable means of host authentication such as TLS client and server certificates.

Источник

Is there a way to find the mac address of a remote machine I have connected to with ssh?

I have machine at the office which is shut off I was hoping to turn it on from home using wake on lan. Reading about this, I have realized that I need the MAC address of the machine. Is there a way to find the MAC address of the machine from my ssh connection history? I use an RSA key to connect to the machine.

If you have access to the DHCP server, possible LDAP database, its nearest router or managed switch it may be possible to get the MAC with some detective skills.

Even if you were able to find the MAC address, you wouldn’t be able to do anything with it. The MAC address only has any use if you can send packets on the same Ethernet segment.

2 Answers 2

No, ssh has nothing to do with MAC addresses. If you are using DHCP you can maybe look into the logs or configuration files to determine the mac address.

WOL has to be enabled to use it (normally a BIOS setting). If you know which port on a switch or router is connected to your target system you might find the MAC in the log-history of that network device.

Thanks. It was a long shot to begin with. The issue is that I have an Idea that I need the machine to test it on and I won’t have access to it until Monday. I was hopping that the sysadmin has enables WOL on that machine.

You must log in to answer this question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.12.43529

Читайте также:  Linux new user home directory

Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way.

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

How do I find the MAC address of a remote computer in Linux?

How do I find the MAC address of a remote computer in Linux?

It’s the command line utility that returns the MAC address along with network protocols associated with each address for all network adapters from local or remote computers. Issue “getmac /s /u username /p password” to view the Physical (MAC) Address of remote system.

How do I find the MAC address of a remote device?

To determine the MAC address of a remote device:

  1. Open the MS-DOS prompt (From the Run… command, type “CMD” and press Enter).
  2. Ping a remote device that you want to find the MAC address (for example: PING 192.168. 0.1).
  3. Type “ARP -A”, and press Enter.

How do I find my MAC address Ubuntu?

Open the Activities overview and start typing Network. Click on Network to open the panel. Choose which device, Wi-Fi or Wired, from the left pane. The MAC address for the wired device will be displayed as the Hardware Address on the right.

How do I find MAC address?

  1. Click Start or click in the search box and type cmd.
  2. Press Enter, or click on the Command Prompt shortcut.
  3. In the Command Prompt window, type ipconfig /all and press enter.
  4. Multiple adapters may be listed. Each adapter should have a Physical Address. The Physical Address is the adapter’s MAC address.

Can you ping a MAC address Linux?

The easiest way to ping a MAC address on Linux is to use the “arping” command and to specify the IP address to be pinged. Similarly to Windows, if the host pings back, you will be presented with the MAC address you are interested in.

How do I find my MAC address Ubuntu terminal?

To get your computer’s Wired or Wireless MAC address from the Terminal Screen: Locate and open Terminal from Applications->Utilities->Terminal. At the Terminal Prompt, type ifconfig and press Enter. This will list all of your network settings, including the physical addresses of your wired and wireless hardware.

How do I find my MAC address in terminal?

Open a terminal. Type ifconfig -a and press Enter. -> HWaddr or ether or lladdr is the device’s MAC address.

How do I ping a MAC address in terminal?

To initiate a ping test in Mac OS X:

  1. Open Terminal by navigating to /Applications/Utilities.
  2. In the Terminal window type ping , where is the hostname or IP address of the server that you want to ping.
  3. Press Enter.
  4. To stop the ping, after seeing enough results, press Ctrl + C.

How to find the MAC address of a remote computer?

How to find MAC address in Linux command line?

Is it possible to get the MAC address of a different Lan?

Which is an example of a MAC address?

Источник

Оцените статью
Adblock
detector