Detecting if an Xbox 360 is online

0

I have been working on a set of PHP pages that runs on an Apache server on a (Ubuntu) linux box, which returns status and information about the devices on my LAN. One thing that is done is a simple ping test to determine if the device is online with respect to the LAN.

Executing "ping -c 1 -w 1 host" works well with everything except my Xbox 360, which seems to be locked up tight. If I use "nmap -sN xbox360", it will report it is online, but this requires root privileges.

Any ideas on how to solve this problem? I found nothing on the internet on how to enable the Xbox 360 to respond to pings, is there something that doesn't require root privileges (that can be run from a php script) to determine if my Xbox is connected to the LAN?

Robert Mashlan

Posted 2013-07-08T05:55:53.913

Reputation: 1

@RobertMashlan it's also possible the device simply doesn't respond to ping requests... You're better off trying to use nmap -sn (have to run as root), or see this question on Unix.SE: Determine whether XBOX 360 is on for an alternative method using ARP requests.

– Breakthrough – 2015-08-09T17:48:10.583

It could be possible that you cannot ping your xbox because it has built in protection against ping flooding (http://en.wikipedia.org/wiki/Ping_flood)

– agz – 2013-07-08T18:04:12.580

A very useful thing for a device behind a firewalled router on a local lan to have. – Robert Mashlan – 2013-07-08T18:33:53.530

Answers

0

Old question I know, but, my solution (found the question in Google when looking for a solution to my problem)...

On my Raspberry PI, create a script as follows:

#!/bin/bash
SUBNET=192.168.1.
FOUT=/mnt/sda/inbound/hosts.state
FSTATE=/tmp/host.state

for i in `seq 1 255`;
do
    IP=${SUBNET}${i}
    sudo nmap -sP ${IP} | grep "Host up" >/dev/null

    HOSTSTATE=1
    MAC=1
    if [ $? -eq 0 ]; then
            MAC=$(sudo nmap -sP -n ${IP} | grep MAC | cut -d ' ' -f3)
            DATETIME=$(date)
            HOSTSTATE="${IP},${MAC},up"
    else
            HOSTSTATE="${IP},,down"
    fi

    if [ -z "${MAC}" ]; then
            ## HACK FOR grep NOT RETURNING CORRECT EXIT CODE
            HOSTSTATE="${IP},,down"
    fi

    OLDSTATE=""
    if [ -f ${FSTATE} ]; then
            OLDSTATE=$(grep ${IP} ${FSTATE} 2>/dev/null)
    fi
    if [ -z "${OLDSTATE}" ]; then
            OLDSTATE=${IP},,unknown
    fi

    if [ "${OLDSTATE}" != "${HOSTSTATE}" ]; then
            STATE1=$(echo ${OLDSTATE} | cut -d ',' -f3)
            STATE2=$(echo ${HOSTSTATE} | cut -d ',' -f3)
            CHANGE="from ${STATE1} to ${STATE2}"
            CHANGEMSG="${IP},${MAC} changed ${CHANGE} at $( date )"
            echo ${CHANGEMSG} >> ${FOUT}
            grep -v ${IP} ${FSTATE} >> ${FSTATE}.tmp
            echo ${HOSTSTATE} >> ${FSTATE}.tmp
            mv ${FSTATE}.tmp ${FSTATE}
    fi
done

Then edit the user crontab by crontab -e, I set it to:

0,30 * * * * /opt/scripts/checkHostActivity

Finally, add the user to sudoers to allow them to run the nmap commands.

Job jobbed. Every 30 mins, I scan the network to see what hosts are up, and write any changes to /mnt/sda/inbound/host.state

Dave

Posted 2013-07-08T05:55:53.913

Reputation: 101