Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
01-04-2014, 05:41 PM
|
#1
|
LQ Newbie
Registered: Jan 2014
Posts: 2
Rep:
|
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.
|
|
|
01-06-2014, 07:35 AM
|
#2
|
Senior Member
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
|
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.
|
|
|
01-06-2014, 09:21 AM
|
#3
|
Moderator
Registered: Mar 2008
Posts: 22,130
|
Wonder if a different type of packet would be better??? Ping is a poor choice since it can be blocked by too many things.
|
|
|
01-06-2014, 09:47 AM
|
#4
|
LQ Newbie
Registered: Jan 2014
Posts: 2
Original Poster
Rep:
|
Thanks for your input guys, I finally wrote a simple server-client communication, using a UDP port.
Thanks again!
|
|
|
01-06-2014, 11:08 AM
|
#5
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,190
|
Quote:
Originally Posted by paicito
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.
|
|
|
All times are GMT -5. The time now is 12:09 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|