ethernet - Networking - Shared to other Computers - How to find a client's IP address? - Ask Ubuntu
the hardware this:
- laptop internet access via wifi. router practically inaccessible.
- headless banana/raspberry/your-favorite-flavor pi needs sd image , additional packages.
so temporary crossover cable between pi , laptop, setup laptop's ethernet port "shared other computers" (*), image sd card, , boot pi. now, address pi have can ssh it?
i don't have force particular address, like question wants. want know is.
(*) network notification -> edit connections... -> wired connection 1 -> edit button -> ipv4 settings tab -> method = shared other computers
there's couple things can do. assuming you've got single ethernet connection going laptop raspberry, arp-scan
suffice. first , figure out what's name of ethernet interface. in case that's eth3
. thus, here's example:
bash-4.3$ sudo arp-scan -i eth3 --localnet [sudo] password xieerqi: interface: eth3, datalink type: en10mb (ethernet) starting arp-scan 1.8.1 256 hosts (http://www.nta-monitor.com/tools/arp-scan/) 10.42.0.40 b8:27:eb:96:38:91 (unknown) 1 packets received filter, 0 packets dropped kernel ending arp-scan 1.8.1: 256 hosts scanned in 1.459 seconds (175.46 hosts/sec). 1 responded
in output can see raspberry has 10.42.0.40 ip address.
the arp-scan
simple approach , doesn't require sweat. alternative methods can used too. here's few of them:
- knowing network's first 3 octets (for example via
ip addr show eth3
command in case), write simple script pings range of hosts. ( see below python script ). fping
alternative standardping
command, allow host range probed- you can use
nmap
perform host discovery in variety of methods. in particular, command:nmap -e eth3 -sn 10.42.0.0/24
work best - instructsnmap
perform host discovery-sn
option ( underneath hood sends arp requests broadcast mac address), on interface specified-e
option.10.42.0.0/24
cidr notation network. quite simple. wireshark
can used capture packets on ethernet interface. of course , raspberry has send out packets in first place them captured, might not work if don't have "talkative" raspberry. can , however, start capture, filter udp protocol, unplug , plug in raspberry. should see dhcp request , response going itdevices build arp table on time when hosts appear/disappear network, use
arp -a
command.if you're using standard ubuntu , didn't install alternative dhcp servers, can check
dnsmasq
leases file ip assigned devices. instance:bash-4.3$ cat /var/lib/misc/dnsmasq.leases 1479095355 b8:27:eb:96:38:91 10.42.0.40 localhost *
see related question here:dhcp lease raspberry pi not found
nmap
, wireshark
approaches quite useful if have ethernet switch several devices attached it.
since i've mentioned scripting ping
, here's one:
from subprocess import * network = '10.42.0.' num in range(255): = str(num) dn = open('/dev/null','w') try: print('checking ' + network + i) check_call(['ping', '-c','1', '-w', '1','-q',network + i],stdout=dn) except calledprocesserror: pass #print('10.42.0.' + + ' down') else: print('>>> ' + network + + ' up')
this ping range of 256 addresses of network ( 10.42.0.x
) , , indicate of hosts up. ping times out after 1 second, therefore take 256 seconds scan everything. if have 1 raspberry can edit script quit if ip responds ping, speeding process. create number of threads. arp-scan
still remains faster alternative.
Comments
Post a Comment