LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-04-2014, 05:41 PM   #1
paicito
LQ Newbie
 
Registered: Jan 2014
Posts: 2

Rep: Reputation: Disabled
How to listen for a specific ping packet and take an action when it is received


Hi all,

Here is what I am trying to accomplish.
I have two servers, the first one (server A) is always up and the other (server B) only when needed.
The goal is to trigger an action on server A after receiving a specific echo packet from server B:
1) server B comes online
2_a) server B sends a specific ping packet (with a modified size and/or content) to server A
2_b) server A is listening for a specific ping packet (this is the step I am asking your help for)
3) trigger an action on server A when it gets the specific ping packet.

I would like to do it in bash but any other language (perl, python, C, etc.) is OK.

Thanks for your input,
paicito

Last edited by paicito; 01-04-2014 at 05:51 PM.
 
Old 01-06-2014, 07:35 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Some thoughts on this.

use a raw icmp socket server programm. Checkout http://beej.us/guide/bgnet/
use iptables with -m string and -j NFLOG and an nflog programm that runs your programm.
use iptables and -m recent and parse the recent files in /proc and run command. Could also -j SET and search those files.
use ssh and key login from server b to just run a command on server A.
Or write a costum server/client application.
 
Old 01-06-2014, 09:21 AM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,130

Rep: Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639Reputation: 3639
Wonder if a different type of packet would be better??? Ping is a poor choice since it can be blocked by too many things.
 
Old 01-06-2014, 09:47 AM   #4
paicito
LQ Newbie
 
Registered: Jan 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks for your input guys, I finally wrote a simple server-client communication, using a UDP port.

Thanks again!
 
Old 01-06-2014, 11:08 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,190

Rep: Reputation: 8067Reputation: 8067Reputation: 8067Reputation: 8067Reputation: 8067Reputation: 8067Reputation: 8067Reputation: 8067Reputation: 8067Reputation: 8067Reputation: 8067
Quote:
Originally Posted by paicito View Post
Thanks for your input guys, I finally wrote a simple server-client communication, using a UDP port.

Thanks again!
Glad you got it going...but you really should check into portknocking, since that's exactly what you're describing:
http://www.portknocking.org/

There are MANY already-existing scripts (perl and bash), that do this, and the knockd daemon is avaiable to you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
received UDP packet length sasubillis Linux - Software 1 02-12-2010 07:57 AM
Incorrect MAC received on packet, SuSE 10.2 jaguar11735 Linux - Software 5 07-11-2007 06:32 AM
Help. Ping Received stapes SUSE / openSUSE 4 08-18-2006 07:18 PM
problem in received packet linux_lover2005 Programming 2 04-24-2005 08:33 PM
listen the packet in router becky_starr Programming 0 02-18-2004 08:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration