Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Ping and Linux firewall

by BrianDStark (Novice)
on Sep 02, 2015 at 16:14 UTC ( [id://1140812]=perlquestion: print w/replies, xml ) Need Help??

BrianDStark has asked for the wisdom of the Perl Monks concerning the following question:

I am able to ping manually from a windows platform to a linux platform, but I can't ping within my script using Net::Ping. I'm pretty sure this is because Net::Ping does a deeper transaction. I vaguely remember "fixing" this issue with a big hammer by turning off the firewall on my Linux platform. This was OK, since my script was being used in a local network for my own use. I would like to know the more surgical approach, like what firewall setting will allow my Linux platform to respond to the Pings without disabling the firewall all together. I am using Centos 6 and 7. Thanks!

Replies are listed 'Best First'.
Re: Ping and Linux firewall
by trippledubs (Deacon) on Sep 02, 2015 at 16:24 UTC
    By default Net::Ping does a tcp ping. Normal OS pings are usually ICMP. You could try allowing inbound port number 7 to make the TCP Net::Ping work or
    $p = Net::Ping->new("icmp");
    to make your Net::Ping use ICMP protocol.

      Agreed, You will probably have more luck with an ICMP ping.

      One caveat, is that on Linux at least, your perl process will need root to send ICMP packets. (you will find that the ping binary is setuid root on Linux). This might not be an issue on windows as the security tends to be more lax, and you are probably logged in with admin privileges, but it is something to keep in mind.

Re: Ping and Linux firewall
by GotToBTru (Prior) on Sep 02, 2015 at 16:33 UTC

    A quick reading of Net::Ping shows it uses tcp by default, whereas your ping command likely used icmp. You can tell Net::Ping to use icmp. See the synopsis.

    Dum Spiro Spero
Re: Ping and Linux firewall
by Anonymous Monk on Sep 03, 2015 at 12:22 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1140812]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-25 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found