I'm having a problem in my network and I need to know with path the source and destination MAC address of the test environment are taking.
GNU/Linux has any command like this, similar to mtr or traceroute to MAC address?
Best regards.
No. You cannot ping or traceroute a MAC on another network segment.
MAC addresses are used on your local network, when you can just broadcast a message to all network devices. If routers comes into place you need some kind of hierarchy or routing information. So when sending from one network to another you need a protocol like for example IP.
Related
I have a list of hostnames for mixed Linux distros (some Solaris, some RedHat, some Ubuntu), I need to get the IP and MAC for any Ethernet devices on each distro.
I don't have root access to any of these servers, so I wrote a bash script on one that remotely runs on the others and returns IP and MAC parsed from output of ifconfig. Because this script uses an expect file to pass in my password, it takes a long time to execute and is not very elegant.
There has to be a better way to do this. I know of a few tools that can do it for me but unfortunately I can't install any additional packages as I don't have permissions to do so.
The output of arp -a gives exactly what I want, but the problem with this is some of these entries seem to have multiple IPs and hostnames binded to the same MAC address. So I get entries like:
HOSTNAME-1 (IP-1) at SAME_MAC_ADDR [ether] on eth0
HOSTNAME-2 (IP-2) at SAME_MAC_ADDR [ether] on eth0
? (IP-2) at SAME_MAC_ADDR [ether] on eth0
Is there a way to firstly get all IPs and MAC addresses from the list of hostnames I have? I'm guessing arp is what I need here?
Secondly, is there a means to get all additional hostnames or IPs associated with each MAC address if there are duplicates?
The arp command will show the list of MAC address and associated IP addresses of hosts known to the one you are connecting to.
ifconfig is the right tool to use (or "ip a" in some distros). Why don't you try to put a cron job in every machine to store the result of "ip a" or "ifconfig" into a tempfile and instead or executing the command in every remote host, you just donwload this file and parse in your local server?
If not, they only way to get accurate information of network adapters in a *IX box is to get into the host and ask for this info.
Business case:
This is year 2015, and I am using Linux kernel 3.17. My ARM Linux has two NIC, eth0 and eth1. eth0 is for configuration purpose locally for a person next to it, and eth1 is for configuration purpose from remote. So they are basically same function, except eth0 has a person to plug in the cable in the field.
Local PC ------ [eth0 My ARM Linux Computer eth1] ------ Remote PC
Using eth0, the PC software can configure eth1 IP address and port for configuration. To do that, my eth0 has a preset IP address (192.168.1.2) so the PC software can easily find it. The ARM Linux (3.17) application needs to listen on eth0 port A, and eth1 Port B (if configured), and once connected, will respond, but never initiate any activity (not even ping).
There is no connection between local PC and remote PC. They are not supposed to be bridged, or networked.
Question 1:
If eth1 is configured with same IP as eth0, will my application still able to listen on both NIC ports, and correctly respond? I will have two independent threads (maybe same function, but different parameters) to listen on the two NIC ports.
This is why I ask whether I can specify the NIC when connect, and respond, because now you can see they could have same IP address. Ideally, the OS knows where is the connect request is from, so it should know which way to reply to, even if the two NIC have same IP as long as they have different Ethernet address. But, does C++11 or Berkeley model allow me to specify eth0 or eth1 when I listen and reply?
Now, the local PC and remote PC could have same IP address as well (but different from the ARM Linux). But imagine I have two ARM Linux computers, then this configuration is completely ok. But unfortunately I only have one embedded system and one OS with eth0 and eth1.
Question 2:
If answer to question 1 is no, then can they have same subnet mask? Also, can the local PC and remote PC have same IP address?
Assumption
Setting routing table, is a solution, if works. I wanted to know whether it is feasible and also whether it is recommended not to do it.
Also, this is Linux. Similar questions were asked long time ago for Windows, and Windows XP says (no) and I am using Linux 3.17 and I have same IP address so things are different from similar questions.
At the system level, you can configure a bridge on the mediating box. This can have the same IP address on both sides of the bridge and can be locked down using iptables to only respond to particular TCP/UDP ports.
You can't have systems on both sides of the bridge with the same IP address (i.e. the local pc and remote pc can't have the same IP address). You can use ebtables to limit the access on either side of the bridge to the IP address of the bridge itself, which means that the local pc can only talk to the mediating box and the remote pc can only talk to the mediating box.
This is based on never expecting the local and remote pcs to talk to each other.
It's mostly a sys-adminny solution, though, there's not really an API that you could use as a developer to accomplish the same thing.
I'm working on an assignment where I have to grab the ip addresses of the computers on a local network and attempt to discover the associated ethernet address using a script on linux.
I'm up to the point where my script gets all the addresses but I'm not sure how to get the ethernet addresses using that information. The assignment specification says that 'ip' and 'ping' may be helpful but I'm not sure how to use them to query the other computers for their ethernet address.
Any help would be appreciated.
To lookup MAC addresses you could try arp
/usr/sbin/arp
you may need to provide the explicit path to it if its in /usr/sbin unless you are running as root.
Depending on your permission on network you can use nmap ping scan:
nmap -sP 10.168.254.*
or
nmap -sP 10.168.254.0/24
Above command will scan all the host on the network 10.168.254.0 and will give you IP and MAC both.
This would work only for host which are up/visible and allow ping return.
And in your script you shall have to filter the output for mac-ip pair.
You can achieve many solution using nmap, this is the tool for you.
first you can ping an ip address then use arp -a
I have just installed an virtual Linux system. I was trying to access is from a different location but I could get trough.
When I have looked up the ip-address (ifconfig) on the system, which is:
inet addr: 10.0.2.15
but I still cant seem to manage it. Can anyone help?
It depends on virtualizing software you're using, but address pretty much looks like NATed. In that case you can't directly access it, unless you'll configure VM to map virtual network controller directly to host network.
What do you mean with different location? 10.x.x.x are private IP addresses, which can only be accessed within its subnet. What IP address does the host system have?
If the host system is within 192.168.x.x subnet, then an outside computer cannot know how to access 10.x.x.x when there is no route. You have then to set up NAT on your host computer.
A more easier approach would be to use bridged networking which will then eventually get an IP address through DHCP from your router (or whatever you might have).
I want to build a MAC address spoofer that spits out a randomize mac address everytime my computer boots up. My question is how and from where do all my computer programs in linux pull up my MAC address. I know that my wi-fi network driver is responsible for telling my network card what to send, but from where does that driver get my MAC address? I also know that a MAC address is called a hardware address, however since it is possible to spoof MAC addresses, then it must only mean that the MAC address on my network card doesn't have to be used when sending information. I would like to know how this can be done as well.
Also when randomizing my MAC address this ought to work with all other programs such as my web-browser and whatever else that I use, which shouldn't be a problem since thats really an application layer ... not link layer
Thanks
The MAC address is usually stored in some kind of EEPROM on the network card. This address is read during initialization by the network adapter driver and used by the MAC layer when assembling/sending netowrk packets.
The MAC address used can be changed on the command line using "ifconfig" via the "hw" option:
hw class address
Set the hardware address of this interface, if the device driver
supports this operation. The keyword must be followed by the
name of the hardware class and the printable ASCII equivalent of
the hardware address. Hardware classes currently supported
include ether (Ethernet), ax25 (AMPR AX.25), ARCnet and netrom
(AMPR NET/ROM).
ifconfig essentially uses the SIOCSIFHWADDR ioctl (see http://linux.die.net/man/7/netdevice) to set the MAC address.
In some cases it might even be possible to change the MAC address stored on the network adapter itself, see http://linux.die.net/man/8/ethtool - but I wouldn't recommend doing that.
The only thing that cares about your MAC address is the NIC itself. There should be no programs that use the MAC address (including browsers). Since MAC addresses are used on the physical layer -- that's the only thing that will read your MAC (such as routers, switches, etc).
To set the MAC address of your NIC you can use the ifconfig command: ifconfig eth0 hw ether ##:##:##:##:##:## (you might have to take your network down first, set it, and then bring it up. IE: ifconfig eth0 down; ifconfig eth0 hw ether ##:##:##:##:##:#; ifconfig eth0 up)