# sending a magic packet triggered  from iptables [solved]

## dermund

Hi

I want to wakeup up my music server if my Xbox360 is powered up. My router in the middle runs linux and iptables. Is it (and how) possible to capture whatever the xbox sends at startup [I guess it will send some stuff] from iptables and trigger a external program that sends a magic packet to wakeup the server?

My problem can nearly be narrowed to the iptables thing: How do I capture this xbox stuff and how do I trigger a external program with iptables rules.

T h a n k s

D e r m u n dLast edited by dermund on Thu Mar 13, 2008 10:18 pm; edited 1 time in total

----------

## Zepp

 *dermund wrote:*   

> Hi
> 
> I want to wakeup up my music server if my Xbox360 is powered up. My router in the middle runs linux and iptables. Is it (and how) possible to capture whatever the xbox sends at startup [I guess it will send some stuff] from iptables and trigger a external program that sends a magic packet to wakeup the server?
> 
> My problem can nearly be narrowed to the iptables thing: How do I capture this xbox stuff and how do I trigger a external program with iptables rules.
> ...

 

You can probably trigger the event when the Xbox requests an ip address via DHCP. Assuming you are using dhcp.

Another suggestion would be to just listen for connection requests to Xbox live's ip/domain address. Assuming it tries to connect to xbox live immediately when it is turned on.

----------

## dermund

 *Quote:*   

> You can probably trigger the event when the Xbox requests an ip address via DHCP. Assuming you are using dhcp. 

 

Yea, I thought of that too. But my real problem - that I have no guess about is how to trigger a external program trough a iptables rule. How does the rule have to look like - if it's possible with iptables at all.

----------

## aronparsons

I don't think an iptables target exists to execute a command.  However, you could use the 'LOG' target, a syslog filter to send matches for that iptables log entry to a certain file and a script that sets up an inotify watch on that log file and when a write event occurs, send the WOL packet.  Maybe there's an easier way, but that would work and shouldn't be too difficult to implement.

Another option is to create a small daemon that sends one ICMP packet to your Xbox's IP every few seconds.  If it replies, send a WOL packet.  It would be more resource intensive (although we're talking about nothing here really).  I had something like this setup to set limits on KTorrent when my XBMC would come up due to limited wireless bandwidth.

----------

## cyrillic

If you run dnsmasq on your router, you could easily use the "dhcp-script=" option in /etc/dnsmasq.conf to trigger an external program when your Xbox360 requests an IP address.

----------

## dermund

Yea, cool, thanks. Both nice ways. ICMP is quick and easy and I think my router could get the workload managed  :Wink:  Thanks for the dhcp-script option however, I will try that too.

 :Very Happy: 

----------

