[SOLVED] How to listen for a specific ping packet and take an action when it is received
Linux - NetworkingThis 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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.