I made some research and can't find a solution, I'm starting to think this is not possible.
I'm running arp -a in my terminal and I'd like to get the hostnames of the LAN devices.
host x.x.x.x returns:
Host x.x.x.x.in-addr.arpa. not found: 3(NXDOMAIN)
nslookup x.x.x.x returns:
** server can't find x.x.x.x.in-addr.arpa: NXDOMAIN
Is there a way to do this?
arp -a does the reverse DNS by default on linux machines. On macOS I guess you will have to run nslookup on each entry returned by arp -a table.
I found a way thanks to #gordon-davisson who set me on the right path.
First I get the gateway IP with: route get default | grep gateway
Then for every LAN device I run: host LAN_IP Gateway_IP
This returns:
Using domain server:
Name: 192.168.x.x
Address: 192.168.x.x#x
Aliases:
x.x.168.192.in-addr.arpa domain name pointer LAN-host-name.
I parse the response to get the name displayed at the end.
Side note: it still doesn't display the LAN host-names with arp -a after that.
Related
This may be something very simple and obvious but I’m learning the command line. I’m trying to identify the IP address I need to load in a web browser to access my local server - for example, after entering these simple steps in the command line to create a folder with an index file:
mkdir www
nano index.html
Then running the server:
sudo python -m SimpleHTTPServer &
Displays this message: [1] 41749
What IP address do I need to load in a web browser to see the test index.html file? I’ve tried:
http://127.0.0.1/
http://localhost/
Also, entering hostname -i returns this message:
hostname: illegal option -- i
usage: hostname [-fs] [name-of-host]
Can anyone explain what’s going on here? Probably something very obvious. Also it feels that other commands aren’t working as usual as the ip addr command now returns -bash: ip: command not found.
Thanks for any help here.
I have trouble with dnsmasq - it does not resolve directly defined name.
$ sudo dnsmasq -d -A /test/172.17.0.2 --log-queries &
dnsmasq: started, version 2.48 cachesize 150
dnsmasq: compile time options: IPv6 GNU-getopt DBus no-I18N DHCP TFTP "--bind-interfaces with SO_BINDTODEVICE"
dnsmasq: read /etc/hosts - 2 addresses
$ ping test
ping: unknown host test
What is wrong?
You only set up a server. Your system's resolver (which is used by ping, your browser, and all other applications on your machine) must first know that this server exists and that it should be used. This can be done by modifying /etc/resolv.conf. For first, make sure, this line is in that file:
nameserver 127.0.0.1
But beware: modern systems auto-generate this file and potentially overwrite your changes. So watch out for "DO NOT EDIT THIS FILE BY HAND" comments in that file and instead do what's recommended in the file.
In general, we can find out the DNS server addresses we are using by cat /etc/resolve.conf. However, after dnsmasq is installed, the DNS server address becomes 127.0.0.1 in the file /etc/resolve.conf. How can I find out the real DNS server addresses in this case?
Well, recently I finally find out the way to see which DNS servers are using.
cat /var/log/kern.log | grep nameserver will show the DNS server configuration received by the NetworkManager.
nmcli dev show <IF> | grep DNS will also do that.
cat /var/log/syslog | grep dnsmasq will also tell you which upstream nameservers dnsmasq is using. This may be the most accurate way.
cat /var/run/NetworkManager/resolv.conf also works for me.
Hi i'm look for why my ping command doesn't work when it had a dash in the name for example
Ping HIL-BO
Will get:
Ping request could not find host HIL-BO. Please check the name and try again.
But when i type
Net view
[backslash][backslash] HIL-BO is in the outputted text
why wont this work please help
/Screenshot/
You can not ping to a windows network name except it the same as the DNS entry for your computers IP-address. I'm not a windows user, but the following should work. Try
ipconfig /a
This should show you a list that contains your IP-address. I expect that, you have no DNS entry so you must use the xxx.xxx.xxx.xxx IP-address that will be shown by ipconfig.
ping xxx.xxx.xxx.xxx
(replace the xxx.xxx.xxx.xxx by the displayed address). If you ping the same machine try:
ping localhost
The ping command can only work if the ping service on the target machine is running and the firewall is opend for ICMPv4 protocol and ports.
Working on a shell script that takes a machine name as an argument and then determines if the host is on the local network (same network as the machine that ran the script).
How can I get the IP address from the machine name? Once I get that I should be able to compare that IP with the local one to see if they're on the same subnet.
You can use nslookup (http://linux.die.net/man/1/nslookup), dig (http://linux.die.net/man/1/dig) or host (http://linux.die.net/man/1/host) command-line utilities.
For example, here is the result of running host for getting A-records for stackoverflow.com from DNS server:
$ host -tA stackoverflow.com
stackoverflow.com has address 69.59.197.21
What do you mean by local network? subnet or (windows) domain or within LAN?
You may also have a look at traceroute utility.