Linux HOWTO Enable Miltucast Ping (ICMP) Replies (Echo)

The 2.6 Linux kernel does not respond to multicast ICMP Echo requests by default. This is a setting in /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

Test it:

# cat /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
1
#

Set it to 0 for ping replies:

# echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
# cat /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
0
#

Posted in How Tos, linux, networking | Leave a comment

Build A Custom PERL Installation

If you want to build a PERL installation that is separate from your standard PERL, you can compile one, complete with CPAN support. Just follow these steps:

  1. mkdir /custom/perl/
  2. cd /custom/perl/
  3. curl -O http://www.cpan.org/src/perl-5.12.3.tar.gz
  4. mkdir perl-5_12_3
  5. gunzip perl-5.12.3.tar.gz
  6. tar -xf perl-5.12.3.tar
  7. cd perl-5.12.3
  8. ./Configure -d -Dprefix=/custom/perl/perl-5_12_3
  9. make
  10. make test
  11. make install
  12. /custom/perl/perl-5_12_3/bin/perl -v
  13. /custom/perl/perl-5_12_3/bin/perl -e ‘print “hello world.\n”;’
  14. /custom/perl/perl-5_12_3/bin/perl -MCPAN -e shell
    • Auto configure as much as possible. Step 15 will edit it.
  15. Edit /custom/perl/perl-5_12_3/lib/5.12.3/CPAN/Config.pm
    • Change the following paths:
    • ‘cpan_home’ => q[/custom/perl/perl-5_12_3/cpan/],
    • ‘build_dir’ => q[/custom/perl/perl-5_12_3/cpan/build],
    • ‘histfile’ => q[/custom/perl/perl-5_12_3/cpan/histfile],
    • ‘keep_source_where’ => q[/custom/perl/perl-5_12_3/cpan/sources],
    • ”prefs_dir’ => q[/custom/perl/perl-5_12_3/cpan/prefs],
    • ”urllist’ => [q[ftp://my.cpan.mirror/pub/cpan/]],
  16. Run CPAN and install Bundle::CPAN Bundle::LWP and any required packages
  17. tar -cvf /custom/perl/custom-perl5.12.13.tar /custom/perl/perl-5_12_3/*
  18. gzip /custom/perl/custom-perl5.12.13.tar
  19. Ship custom-perl5.12.13.tar.gz out to your matching architectures or mount it on a shared NAS.
  20. Call it with #!/custom/perl/perl-5_12_3/bin/perl

Did you find this post useful or have questions or comments? Please let me know!

Posted in How Tos, perl, Programming | 2 Comments

How To Pass PERL Library Paths From The Environment

You can have PERL look in different places for libraries and modules using a number of methods. If you find yourself using a custom PERL module repository, you can make sure your PERL programs always reference it without touching the code.

What we’re doing in a nutshell is telling PERL to push values on to the @INC array before loading any modules. You can do this on the command line, in your PERL code or with the environment variable PERL5LIB.

PERL5LIB can contain more than one value. Just set it in you .bashrc file or wherever you see fit. This method works in bash:

export PERL5LIB=/first/path/to/libs"${PERL5LIB:+:$PERL5LIB}"
export PERL5LIB=/second/path/to/libs"${PERL5LIB:+:$PERL5LIB}"
export PERL5LIB=/third/path/to/libs"${PERL5LIB:+:$PERL5LIB}"

You can check what PERL is going to use by printing out the contents of @INC. You can print an array without a loop using join() as I blogged about before:

perl -e 'print join "\n", @INC;'

Let’s put it together:
~$ perl -e 'print join "\n", @INC;'
/etc/perl
/usr/local/lib/perl/5.10.0
/usr/local/share/perl/5.10.0
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.10
/usr/share/perl/5.10
/usr/local/lib/site_perl
.

~$ env|grep -i perl
~$

~$ export PERL5LIB=/first/path/to/libs"${PERL5LIB:+:$PERL5LIB}"
~$ export PERL5LIB=/second/path/to/libs"${PERL5LIB:+:$PERL5LIB}"
~$ export PERL5LIB=/third/path/to/libs"${PERL5LIB:+:$PERL5LIB}"

~$ env|grep -i perl
PERL5LIB=/third/path/to/libs:/second/path/to/libs:/first/path/to/libs

~$ perl -e 'print join "\n", @INC;'
/third/path/to/libs
/second/path/to/libs
/first/path/to/libs
/etc/perl
/usr/local/lib/perl/5.10.0
/usr/local/share/perl/5.10.0
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.10
/usr/share/perl/5.10
/usr/local/lib/site_perl
.

And there it is. Your PERL apps will look in those locations starting from the top.

Did you find this post useful or have questions or comments? Please let me know!

Posted in How Tos, perl, Programming | 3 Comments