Archive for the 'Linux Support' Category

SBDavid

Safety net for Perl

Safety net for Perl

Perl by default is very forgiving. In order to make it more robust it is recommended to start every program with the following lines:

#!/usr/bin/perl
use strict;
use warnings;

The two additional lines request from perl to catch various common problems in your code. They check different things so you need both. A potential problem caught by use strict; will cause your code to stop immediately when it is encountered, while use warnings; will merely give a warning (like the command-line switch -w) and let your code run.

To read more about them check their respective manual pages at strict and warnings.

SBDavid

Block IP Addresses With IPtables

Block IP Addresses With IPtables:

This command will simply drop any packet coming from the address 25.55.55.55. To list the chains:

iptables -I INPUT -s 25.55.55.55 -j DROP

The -n sticks with just IP addresses, rather than resolving the name. This is useful if you have a lot of IP addresses. It can take a lot of time to resolve all of the addresses.

iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all — 25.55.55.55 0.0.0.0/0

If you later decide that you don’t want to drop packets from a particular host, use the -D option instead of -I:

iptables -D INPUT -s 25.55.55.55 -j DROP

Testing Link Status from the Command Line

mii-tool and ethtool commands command will provide reports on the link status and duplex settings for supported NICs.

root@laptop:~# mii-tool
eth0: negotiated 100baseTx-FD flow-control, link ok

ethtool - Display or change ethernet card settings.
ethtool is used for querying settings of an ethernet device and changing them. ethX is the name of the ethernet device on which ethtool should operate. ethtool with a single argument specifying the device name prints current settings of the specified device.

root@laptop:~# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Current message level: 0×00000000 (0)
Link detected: yes

How to check packet Flows using tcpdump

Tcpdump prints out a description of the contents of packets on a network interface that match the boolean expression. It can also be run with the -w flag, which causes it to save the packet data to a file for later analysis, and/or with the -r flag, which causes it to read from a saved packet file rather than to read packets from a network interface. In all cases, only packets that match expression will be processed by tcpdump.

One of the most common uses of tcpdump is to determine whether you are getting basic two-way communication.

Command Options:

icmp View icmp packets
tcp port port-number View TCP packets with packets with either a source or destination TCP port of port-number
udp port port-number View UDP packets with either a source or destination UDP port of port-number

Example:

tcpdump -i eth0 icmp

By using the -w filename option you can send the entire Ethernet frame, not just a brief IP information that normally goes to the screen, to a file. This can then be analyzed by graphical analysis tools such as Wireshark, which is available in both Windows and Linux

tcpdump -i eth0 -w /tmp/tcp.dump tcp port 22

The -n switch stops DNS name lookups and will make tcpdump work more reliably.

tcpdump -i eth0 -n tcp port 22
SBDavid

Cluster Basis & type of Clusters

Cluster Basis & type of Clusters.

Two or more computers that work together to perform a task is called a cluster.

Example:

Storage Cluster Provides a consistent file system image across servers in a cluster, which allows servers to simultaneously read and write to a single shared file system.

Type of clusters:

Load Balancing cluster to dispatch network service requests to multiple cluster nodes.
Storage cluster to provide consistent file system storage image.
High Performance cluster to perform concurrent calculations for applications.
High Availability or Fail-over clusters provides continuous availability of services.

Example:

Red Hat Cluster is an integrated set of software components. RHCS consists of the following major, components.

Cluster infrastructure - which Provides fundamental functions for nodes to work together as a cluster.
High-availability Service Management — Provides failover of services from one cluster node to another in case a node becomes inoperative.
Cluster administration tools — Configuration and management tools for setting up, configuring, and managing a Red Hat cluster.
Linux Virtual Server (LVS) — Routing software that provides IP-Load-balancing.

Other optional package (and not part of Red Hat Cluster Suite) are as follows:

GFS (Global File System) and GFS2 (Global File System2) allows multiple nodes to share storage at a block level as if the storage were connected locally to each cluster node.

Cluster Logical Volume Manager (CLVM) — Provides volume management of cluster storage.

« Prev - Next »