Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to determine the IP of my Raspberry Pi which is attached to my PC via Ethernet and has a dynamic IP.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Option 1:
Look into your DHCP Server. If it displays all DHCP leases, you can see it there.

Option 2:
Or try to find it in your arp table if you know your Raspberry PI's MAC address. Open a cmd prompt for that and type arp -a. It then shows you a list of all known IP-MAC pairs. If it's not in there, try to ping your broadcast address and enter arp -a again. The broadcast IP is always the last IP in your subnet. For example the broadcast IP of subnet 192.168.0.0 is 192.168.0.255.

Option 3:
You could also scan all devices in your network for an open port if you know a specific port that is only open on your Raspberry Pi. Say, your Raspberry Pi is open on port 80, you could scan all IP addresses in your subnet for port 80. If you don't have too much Webservers in your network (maybe only a few printers and routers of which you know the IP address of course), you will find your Raspberry Pi very quick.
Sadly, I don't know how to use nmap because I use a Powershell script to scan ports. I could paste it here if you want to try it. Simply let me know in the comments if you'd like to try my script.

Edit: Here's my script. Usage below.

function Test-Port {

param(
        [parameter(Position=0)][string[]]$Computer=(Read-Host "Target: "),
        [parameter(Position=1)][string[]]$Port=(Read-Host "Ziel-Port: "),
        [int]$Timeout=1000
)

$ErrorActionPreference = "SilentlyContinue"
$ResultObjects = @()

foreach ($Target in $Computer) {
    foreach ($p in $Port) {
        $ResultObjects += P_Test-Port
    } # end port foreach
} #end target foreach

return $ResultObjects
} #end function

function P_Test-Port {

        $tcpclient = new-object system.net.sockets.tcpclient
        $con = $tcpclient.BeginConnect($Target,$p,$null,$null)
        $wait = $con.AsyncWaitHandle.WaitOne($timeout,$false)
        [bool]$Open = $false

        # check the connection
        if(!$wait)
        {
            # close connection and report timeout
            $tcpclient.Close()
            [string]$result = ("Connection Timeout (" + $Timeout + " ms)")
            $failed = $true
        } else {
            $error.Clear()
            $tcpclient.EndConnect($con) | out-null
            if(!$?){[string]$result = ("Closed / Filtered");$failed = $true}
            $tcpclient.Close()
        }
        if(!$failed){
            [string]$result = ("Open")
            $failed = $false
            $Open = $true
        } 



        $objTestPortResult = new-object System.Object
        $objTestPortResult | Add-Member -type NoteProperty -name Host -value $Target
        $objTestPortResult | Add-Member -type NoteProperty -name Port -value $p
        $objTestPortResult | Add-Member -type NoteProperty -name Result -value $result
        $objTestPortResult | Add-Member -type NoteProperty -name Open -value $Open

        return $objTestPortResult
}

Copy this script and paste it into your powershell. You can then use it as follows:
Test-Port <IP-Address[]> <Port[]>

Example: Test-Port 192.168.0.1,AnyComputerName 80,443
This will scan the computers 192.168.0.1 and AnyComputerName for open ports 80and 443. You can simply pass one argument for Computername and Port or pass multiple comma separated values.

To scan your whole subnet for port 80 you would do this as follows (assuming you're using subnet 192.168.0.0/24):
$ips = 1..254 | Foreach-Object { "192.168.0.$_" } ; Test-Port $ips 80

Let me know if you need more information or simply give me the port that you want to scan for, I'll create your command for you then.

share|improve this answer
    
Yes please could you please post it. –  gbhall Aug 12 '12 at 12:52
    
Appended my portscan script with short usage explanation... –  wullxz Aug 12 '12 at 13:03
    
Thank you so much! You're an absolute legend! Looping through all IPs searching for port 22 did the trick. Brilliant script and I thank you again for all of your help. Hopefully it will help many more people because researching this not many easy solutions like the one given (albeit you had to write the script) were available. –  gbhall Aug 12 '12 at 13:42
    
No problem. I just copied that script. It helped me many times before ;) btw: forgot to tell you how to filter the results. By adding | ? { $_.open -eq $true } you can just display the results where the port is open. –  wullxz Aug 12 '12 at 14:02
    
Legend! Thank you again. Definitely keeping this in my toolkit. –  gbhall Aug 12 '12 at 14:27

If you know the RasPi host name you can just ping it. If it responds tot the ping, it'll tell you it's IP address.

No script needed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.