Find details of device based on dns name using ip command
up vote
0
down vote
favorite
When I'm retrieving the mac address of a device
I execute following command
$ arp <dnsname> | grep "HWaddress" -A1 | awk '{print $1 "" $3}' |head -2 | tail -1
this will probably print
<dnsname> <mac address>
As I've seen from the manual of arp is that it is deprecated and alternate I have is to use 'ip' command instead of arp .
linux dns ip arp
add a comment |
up vote
0
down vote
favorite
When I'm retrieving the mac address of a device
I execute following command
$ arp <dnsname> | grep "HWaddress" -A1 | awk '{print $1 "" $3}' |head -2 | tail -1
this will probably print
<dnsname> <mac address>
As I've seen from the manual of arp is that it is deprecated and alternate I have is to use 'ip' command instead of arp .
linux dns ip arp
Your question is not clear. Do you want to obtain the mac address using ip command?
– Helio
Sep 20 '17 at 19:33
Do you want to retrieve the MAC address of the device running this code, or of some arbitrary device on the same LAN?
– roaima
Sep 20 '17 at 20:42
@Helio my input is dnsname and my required output is mac address. by above command I can do it easily but arp is depricated and i was suggested to use 'ip'. so I need to achieve the same result using 'ip'
– Harish Barma
Sep 21 '17 at 8:23
@roaima I will pass the dnsname in the local network and fetch the mac address
– Harish Barma
Sep 21 '17 at 8:24
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
When I'm retrieving the mac address of a device
I execute following command
$ arp <dnsname> | grep "HWaddress" -A1 | awk '{print $1 "" $3}' |head -2 | tail -1
this will probably print
<dnsname> <mac address>
As I've seen from the manual of arp is that it is deprecated and alternate I have is to use 'ip' command instead of arp .
linux dns ip arp
When I'm retrieving the mac address of a device
I execute following command
$ arp <dnsname> | grep "HWaddress" -A1 | awk '{print $1 "" $3}' |head -2 | tail -1
this will probably print
<dnsname> <mac address>
As I've seen from the manual of arp is that it is deprecated and alternate I have is to use 'ip' command instead of arp .
linux dns ip arp
linux dns ip arp
edited Nov 24 at 20:41
Rui F Ribeiro
38.3k1475126
38.3k1475126
asked Sep 20 '17 at 15:15
Harish Barma
1032
1032
Your question is not clear. Do you want to obtain the mac address using ip command?
– Helio
Sep 20 '17 at 19:33
Do you want to retrieve the MAC address of the device running this code, or of some arbitrary device on the same LAN?
– roaima
Sep 20 '17 at 20:42
@Helio my input is dnsname and my required output is mac address. by above command I can do it easily but arp is depricated and i was suggested to use 'ip'. so I need to achieve the same result using 'ip'
– Harish Barma
Sep 21 '17 at 8:23
@roaima I will pass the dnsname in the local network and fetch the mac address
– Harish Barma
Sep 21 '17 at 8:24
add a comment |
Your question is not clear. Do you want to obtain the mac address using ip command?
– Helio
Sep 20 '17 at 19:33
Do you want to retrieve the MAC address of the device running this code, or of some arbitrary device on the same LAN?
– roaima
Sep 20 '17 at 20:42
@Helio my input is dnsname and my required output is mac address. by above command I can do it easily but arp is depricated and i was suggested to use 'ip'. so I need to achieve the same result using 'ip'
– Harish Barma
Sep 21 '17 at 8:23
@roaima I will pass the dnsname in the local network and fetch the mac address
– Harish Barma
Sep 21 '17 at 8:24
Your question is not clear. Do you want to obtain the mac address using ip command?
– Helio
Sep 20 '17 at 19:33
Your question is not clear. Do you want to obtain the mac address using ip command?
– Helio
Sep 20 '17 at 19:33
Do you want to retrieve the MAC address of the device running this code, or of some arbitrary device on the same LAN?
– roaima
Sep 20 '17 at 20:42
Do you want to retrieve the MAC address of the device running this code, or of some arbitrary device on the same LAN?
– roaima
Sep 20 '17 at 20:42
@Helio my input is dnsname and my required output is mac address. by above command I can do it easily but arp is depricated and i was suggested to use 'ip'. so I need to achieve the same result using 'ip'
– Harish Barma
Sep 21 '17 at 8:23
@Helio my input is dnsname and my required output is mac address. by above command I can do it easily but arp is depricated and i was suggested to use 'ip'. so I need to achieve the same result using 'ip'
– Harish Barma
Sep 21 '17 at 8:23
@roaima I will pass the dnsname in the local network and fetch the mac address
– Harish Barma
Sep 21 '17 at 8:24
@roaima I will pass the dnsname in the local network and fetch the mac address
– Harish Barma
Sep 21 '17 at 8:24
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
arp
is able to take names as input and print names in output. ip
uses addresses only.
If you can deal with addresses, then modifying the output is pretty easy.
$ ip neigh show to 10.0.0.1
10.0.0.1 dev wlan0 lladdr dc:fb:02:xx:xx:xx REACHABLE
$ ip neigh show to 10.0.0.1 | awk '{print $1 " " $5}'
10.0.0.1 dc:fb:02:xx:xx:xx
I just noticed that your title specifically asks about DNS names. If that's the requirement, then you'll want to translate the name in your script.
$ ip neigh show to `getent hosts <dnsname> | awk '{print $1}'` | awk '{print $1 " " $5}'
$ 10.0.0.1 dc:fb:02:xx:xx:xx
You'll be better using$( ... )
instead of backticks, i.e.ip neigh show to $(getent hosts <dnsname> | awk '{print $1}') | awk '{print $1 " " $5}'
– roaima
Sep 21 '17 at 10:11
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
arp
is able to take names as input and print names in output. ip
uses addresses only.
If you can deal with addresses, then modifying the output is pretty easy.
$ ip neigh show to 10.0.0.1
10.0.0.1 dev wlan0 lladdr dc:fb:02:xx:xx:xx REACHABLE
$ ip neigh show to 10.0.0.1 | awk '{print $1 " " $5}'
10.0.0.1 dc:fb:02:xx:xx:xx
I just noticed that your title specifically asks about DNS names. If that's the requirement, then you'll want to translate the name in your script.
$ ip neigh show to `getent hosts <dnsname> | awk '{print $1}'` | awk '{print $1 " " $5}'
$ 10.0.0.1 dc:fb:02:xx:xx:xx
You'll be better using$( ... )
instead of backticks, i.e.ip neigh show to $(getent hosts <dnsname> | awk '{print $1}') | awk '{print $1 " " $5}'
– roaima
Sep 21 '17 at 10:11
add a comment |
up vote
1
down vote
accepted
arp
is able to take names as input and print names in output. ip
uses addresses only.
If you can deal with addresses, then modifying the output is pretty easy.
$ ip neigh show to 10.0.0.1
10.0.0.1 dev wlan0 lladdr dc:fb:02:xx:xx:xx REACHABLE
$ ip neigh show to 10.0.0.1 | awk '{print $1 " " $5}'
10.0.0.1 dc:fb:02:xx:xx:xx
I just noticed that your title specifically asks about DNS names. If that's the requirement, then you'll want to translate the name in your script.
$ ip neigh show to `getent hosts <dnsname> | awk '{print $1}'` | awk '{print $1 " " $5}'
$ 10.0.0.1 dc:fb:02:xx:xx:xx
You'll be better using$( ... )
instead of backticks, i.e.ip neigh show to $(getent hosts <dnsname> | awk '{print $1}') | awk '{print $1 " " $5}'
– roaima
Sep 21 '17 at 10:11
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
arp
is able to take names as input and print names in output. ip
uses addresses only.
If you can deal with addresses, then modifying the output is pretty easy.
$ ip neigh show to 10.0.0.1
10.0.0.1 dev wlan0 lladdr dc:fb:02:xx:xx:xx REACHABLE
$ ip neigh show to 10.0.0.1 | awk '{print $1 " " $5}'
10.0.0.1 dc:fb:02:xx:xx:xx
I just noticed that your title specifically asks about DNS names. If that's the requirement, then you'll want to translate the name in your script.
$ ip neigh show to `getent hosts <dnsname> | awk '{print $1}'` | awk '{print $1 " " $5}'
$ 10.0.0.1 dc:fb:02:xx:xx:xx
arp
is able to take names as input and print names in output. ip
uses addresses only.
If you can deal with addresses, then modifying the output is pretty easy.
$ ip neigh show to 10.0.0.1
10.0.0.1 dev wlan0 lladdr dc:fb:02:xx:xx:xx REACHABLE
$ ip neigh show to 10.0.0.1 | awk '{print $1 " " $5}'
10.0.0.1 dc:fb:02:xx:xx:xx
I just noticed that your title specifically asks about DNS names. If that's the requirement, then you'll want to translate the name in your script.
$ ip neigh show to `getent hosts <dnsname> | awk '{print $1}'` | awk '{print $1 " " $5}'
$ 10.0.0.1 dc:fb:02:xx:xx:xx
edited Sep 20 '17 at 22:11
answered Sep 20 '17 at 21:59
BowlOfRed
2,425715
2,425715
You'll be better using$( ... )
instead of backticks, i.e.ip neigh show to $(getent hosts <dnsname> | awk '{print $1}') | awk '{print $1 " " $5}'
– roaima
Sep 21 '17 at 10:11
add a comment |
You'll be better using$( ... )
instead of backticks, i.e.ip neigh show to $(getent hosts <dnsname> | awk '{print $1}') | awk '{print $1 " " $5}'
– roaima
Sep 21 '17 at 10:11
You'll be better using
$( ... )
instead of backticks, i.e. ip neigh show to $(getent hosts <dnsname> | awk '{print $1}') | awk '{print $1 " " $5}'
– roaima
Sep 21 '17 at 10:11
You'll be better using
$( ... )
instead of backticks, i.e. ip neigh show to $(getent hosts <dnsname> | awk '{print $1}') | awk '{print $1 " " $5}'
– roaima
Sep 21 '17 at 10:11
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f393430%2ffind-details-of-device-based-on-dns-name-using-ip-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Your question is not clear. Do you want to obtain the mac address using ip command?
– Helio
Sep 20 '17 at 19:33
Do you want to retrieve the MAC address of the device running this code, or of some arbitrary device on the same LAN?
– roaima
Sep 20 '17 at 20:42
@Helio my input is dnsname and my required output is mac address. by above command I can do it easily but arp is depricated and i was suggested to use 'ip'. so I need to achieve the same result using 'ip'
– Harish Barma
Sep 21 '17 at 8:23
@roaima I will pass the dnsname in the local network and fetch the mac address
– Harish Barma
Sep 21 '17 at 8:24