Thursday, November 5, 2009

Mbox vs Maildir: Mail Storage Formats

— SkyHi @ Thursday, November 05, 2009
The Unix world has two ways of storing mail messages, the traditional mbox format and the newer maildir format. Postfix and Dovecot supports the two mail storage format so you can use any format, but I highly recommend you use the maildir format.
The Mbox Format

This is the traditional way of storing mail messages in the Unix world. In this format, a regular text file which serves as the mail user’s mailbox file is created.
Mbox storage format

Fig. 1: Mbox storage format
How Mbox works
Receiving and storing a mail

1. Lock the mailbox.
2. Append the header (usually “From [sender's email address] [date and time received]“) and the mail into the mailbox file.
3. Unlock the mailbox.

Retrieving a mail

1. Lock the mailbox.
2. Locate and read the mail.
3. Update the mail status flag.
4. Unlock the mailbox.

Deleting a mail

1. Lock the mailbox.
2. Move the contents of the mailbox, beginning from the position right after the mail to be deleted until the end of the mailbox, into the position of the mail to be deleted.
3. Reduce the size of the mailbox file by the size of the deleted mail.
4. Unlock the mailbox.

Searching a mail

1. Lock the mailbox.
2. Search the mailbox.
3. Unlock the mailbox.


Advantages

* Format is universally supported.
* Appending a new mail into the mailbox file is fast.
* Searching text inside a single mailbox file is fast.

Disadvantages

* Has file locking problems.
* Has problems when used with network file systems.
* Format is prone to corruption.


The Maildir Format

This is a new way of storing mail messages. In this format, a directory usually named Maildir is created for each mail user. Under this directory are three more directories named new, cur and tmp.
Maildir storage format

Fig. 2: Maildir storage format
How Maildir works
Receiving and storing a mail

1. Create a unique file in the tmp directory.
2. Write the mail into the newly created file.
3. Move the completely written mail into the new directory.

Retrieving a mail

1. Locate and read the mail.
2. Move the mail from new into the cur directory and append the mail status flag into the filename.

Deleting a mail

1. Delete the file containing the mail.

Searching a mail

1. Search each and every mail file.


Advantages

* Locating, retrieving and deleting a specific mail is fast.
* Minimal to no file locking needed.
* Can be used on network file system.
* Immune to mailbox corruption (assuming the hardware will not fail).

Disadvantages

* Some filesystems may not efficiently handle a large number of small files.
* Searching text, which requires all mail files to be opened is slow.

Visit the forum to ask for help or to give a comment.

Reference: http://www.linuxmail.info/mbox-maildir-mail-storage-formats/

smrsh - restricted shell for sendmail

— SkyHi @ Thursday, November 05, 2009
Synopsis
smrsh -c command
Description
The smrsh program is intended as a replacement for sh for use in the ''prog'' mailer in sendmail(8) configuration files. It sharply limits the commands that can be run using the ''|program'' syntax of sendmail in order to improve the over all security of your system. Briefly, even if a ''bad guy'' can get sendmail to run a program without going through an alias or forward file, smrsh limits the set of programs that he or she can execute.

Briefly, smrsh limits programs to be in a single directory, by default /etc/smrsh, allowing the system administrator to choose the set of acceptable commands, and to the shell builtin commands ''exec'', ''exit'', and ''echo''. It also rejects any commands with the characters ''', '<', '>', ';', '$', '(', ')', '\r' (carriage return), or '\n' (newline) on the command line to prevent ''end run'' attacks. It allows ''||'' and ''&&'' to enable commands like: ''"|exec /usr/local/bin/filter || exit 75"''

Initial pathnames on programs are stripped, so forwarding to ''/usr/ucb/vacation'', ''/usr/bin/vacation'', ''/home/server/mydir/bin/vacation'', and ''vacation'' all actually forward to ''/etc/smrsh/vacation''.

System administrators should be conservative about populating the /etc/smrsh directory. For example, a reasonable additions is vacation(1), and the like. No matter how brow-beaten you may be, never include any shell or shell-like program (such as perl(1)) in the /etc/smrsh directory. Note that this does not restrict the use of shell or perl scripts in the sm.bin directory (using the ''#!'' syntax); it simply disallows execution of arbitrary programs. Also, including mail filtering programs such as procmail(1) is a very bad idea. procmail(1) allows users to run arbitrary programs in their procmailrc(5).
Files
/etc/smrsh - directory for restricted programs
See Also
sendmail(8)

Why do I get the message "(killed lost mailbox lock)" user=... host=...?

— SkyHi @ Thursday, November 05, 2009
Solution The traditional UNIX mailbox format or MMDF format is only allows one session to have the mailbox open read/write at a time. So, the email server assumes that if a second session attempts to open the mailbox, that means that the first session is probably owned by an abandoned client. The common scenario here is a user who leaves his client running at the office, and then tries to read his mail from home. Through an internal mechanism called kiss of death, the second session requests the first session to kill itself. When the first session receives the "kiss of death", it issues the "Killed (lost mailbox lock)" syslog message and terminates. The second session then seizes read/write access, and becomes the new "first" session.

Certain poorly-designed clients routinely open multiple sessions to the same mailbox; the users of those clients tend to get this message a lot.

Another cause of this message is a background "check for new mail" task which does its work by opening a POP session to server every few seconds. They do this because POP doesn't have a way to announce new mail.


Reference: http://www.alphaone-tech.com/tech-support/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=67



I've just fixed this myself on one of our servers - the problem is that the standard mailbox format used is mbox, which doesn't support concurrent users. To get around this, you need to convert the Inbox to mbx which offers faster access and concurrent access so therefore fixes the problem. Nothing on the server needs to be reconfigured for this as mbx is supported as well anyway. You will need to do the following:

change into the users home directory:

cd /home/virtual/domain.com/home/user

Download an mbx format inbox (this does not overwrite your existing mail - this is just a blank one that I've created as well)

wget http://www.penguin-uk.com/ensim/INBOX

Check your mail via IMAP then and it will configure itself on the first go. Problem then solved

Reference: http://forums.theplanet.com/index.php?showtopic=60982

Wednesday, November 4, 2009

How do I import delimited data into MySQL?

— SkyHi @ Wednesday, November 04, 2009
f you have data that you need to bring into your MySQL database, there are a few ways to do it. Exporting data out of mysql is another topic, described here.

1. Using the LOAD DATA INFILE SQL statement

For security reasons, no one has the mysql FILE priv, which means you cannot "LOAD DATA INFILE". You can, however, use a "LOAD DATA LOCAL INFILE" statement as long as you have a mysql prompt on our system and have uploaded the data file to your account here first.

The "LOAD DATA LOCAL INFILE" statement will only work from a MySQL prompt on our local system. It will not work from any web-based tool such as phpMyAdmin, and will never pull a file in directly off your own computer.

To import a file this way, first upload your data file to your home directory on our system with FTP or SCP. Then get a shell prompt on our system, and then a MySQL Monitor prompt so that you can issue the SQL that will import your file.

For example, suppose you have a data file named importfile.csv that contains 3 comma separated columns of data on each line. You want to import this textfile into your MySQL table named test_table, which has 3 columns that are named field1, field2 and field3.

To import the datafile, first upload it to your home directory, so that the file is now located at /importfile.csv on our local system. Then you type the following SQL at the mysql prompt:

LOAD DATA LOCAL INFILE '/importfile.csv'
INTO TABLE test_table
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(field1, filed2, field3);

The above SQL statement tells the MySQL server to find your INFILE on the LOCAL filesystem, to read each line of the file as a separate row, to treat any comma character as a column delimiter, and to put it into your MySQL test_table as columns field1, field2, and field3 respectively. Many of the above SQL clauses are optional and you should read the MySQL documentation on the proper use of this statement.

2. Using a script to parse and import the file

You can also write a script in any programming language that can connect to MySQL (such as PHP) to open your data file, break it up into an array of lines that each represent a row of data, split each line up by the delimiter character (such as a comma ',', tab '\t', semicolon ';', space ' ', etc.), and then perform invididual MySQL INSERT queries (one INSERT for each line) to insert all your data from the file into the appropriate table fields.

Such scripts are not difficult to write in less than 15 lines and can import data from text files just as effectively as a LOAD DATA LOCAL INFILE command. A working example script written in PHP appears below in the Annotations.

3. Importing a mysqldump

If your data file actually comes from another MySQL database, and not from Excel or any other source, then the most direct way to export and import your data would be to dump out your table or entire MySQL database on the original database server using the mysqldump command, FTP the resulting dump file to your account here, and then import the dump file at a shell


# first get a mysql connection as per the FAQ

$fcontents = file ('./spreadsheet.xls');
# expects the csv file to be in the same dir as this script

for($i=0; $i $line = trim($fcontents[$i]);
$arr = explode("\t", $line);
#if your data is comma separated
# instead of tab separated,
# change the '\t' above to ','

$sql = "insert into TABLENAME values ('".
implode("','", $arr) ."')";
mysql_query($sql);
echo $sql ."
\n";
if(mysql_error()) {
echo mysql_error() ."
\n";
}
}
?>

Upload a spreadsheet file into the same directory as this script. Then
you edit this script to put in the correct table name instead of
"TABLENAME".

So long as your xls file is tab delimited and has 1 row per line with
all columns in the same order that your mysql database columns are, then
this script will pull all the data out of your XLS file and insert it
all into mysql. Don't forget to connect to mysql in the script before
anything else with a mysql_connect() and mysql_select_db() as shown here
http://www.modwest.com/help/kb6-60.html

Reference: http://www.modwest.com/help/kb6-253.html

Tuesday, November 3, 2009

Ubuntu Karmic Koala (9.10 Beta) Buggy Touchpad Behavior

— SkyHi @ Tuesday, November 03, 2009
Ubuntu Karmic Koala (9.10 Beta) Buggy Touchpad Behavior

17 Oct 09 by Danilo

I recently upgraded my Dell Precision M90 Laptop to Ubuntu Karmic Koala. I’m running it standalone, no Windows anywhere. When I upgraded using “apt-get upgrade” my touchpad didn’t work. Nothing. The touchpad was completely disabled. I assume that this is a problem on M70’s, ect.

Found a fix after searching for two days — in case you’re having the same problem, here it is.

Open a terminal (if you don’t have a mouse hooked up, use Alt+F2). then “su” and give the root password (I tried doing this with sudo and still didn’t have enough permission. I “think” you need to be root). At the prompt, type:

echo options psmouse proto=exps > /etc/modprobe.d/psmouse.modprobe

At the next prompt, type”

reboot

Your touchpad will come back up after rebooting.

Reference: http://danilogurovich.wordpress.com/2009/10/17/ubuntu-karmic-koala-9-10-beta-buggy-touchpad-behavior/

Linux – disk usage (du) human readable AND sorted by size

— SkyHi @ Tuesday, November 03, 2009
This is quick tip to fix a problem that has always bugged me – When showing disk usage in a human readable form (KB, MB, GB) for each subdirectory using “du -sh *”, how can you properly sort it into size order.

If you just want the solution here it it…

alias duf='du -sk * | sort -n | perl -ne '\''($s,$f)=split(m{\t});for (qw(K M G)) {if($s<1024) {printf("%.1f",$s);print "$_\t$f"; last};$s=$s/1024}'\' Put it into ~/.bashrc to make it permanent. But if you can spare a minute or two you might get some ideas about how to write those programmatic aliases, in this case using perl. When using the linux “du” command I like to make the file size human readable, so 8709100 becomes 8.4G, This is achieved by doing this: du -sh * Now, the main problem with the K, M and G filesize suffixes is that you can’t sort them. If you try to pipe that through sort by using du -sh * | sort you’ll get something like this 8.4G Desktop 2.6G Documents 12K keys 12M Pictures 536K scripts or if we sort numerically du -sh * | sort -n you’ll get something like this 2.6G Documents 8.4G Desktop 12K keys 12M Pictures 536K scripts Obviously both these commands are not working as we are intending, because the K(ilo) M(ega) G(iga) suffixes mess up “sort”, The solution is a one liner wrapped up into an alias ‘duf’ for ‘disk usage formatted’ alias duf='du -sk * | sort -n | perl -ne '\''($s,$f)=split(m{\t});for (qw(K M G)) {if($s<1024) {printf("%.1f",$s);print "$_\t$f"; last};$s=$s/1024}'\' When expanded out, formatted and commented the code looks like this

du -sk * | sort -n | //get usage in KBytes and sort
perl -ne ' //we use perl to reformat the filesize in K M & G
($s,$f)=split(m{\t}); //splits the size/filename pair
for (qw(K M G)) { //loops for each size
if($s<1024) { //if s<1024 weve found the correct suffix printf("%.1f",$s); //display the size print "$_\t$f"; //display the filename last //line completed }; $s=$s/1024 //for each sizes suffix divide by 1024 }'


du -h --max-depth=1


This produces the output we intended like this.

12.0KB keys
536.0KB scripts
11.7MB Pictures
2.5GB Documents
8.3GB Desktop

Here some useful additions that are worth adding as an edit to my original post:

1) Purely as a shell script, without the perl overhead - source 'inataysia' reddit
du -sk * | sort -n | while read size fname; do for unit in k M G T P E Z Y; do if [ $size -lt 1024 ]; then echo -e "${size}${unit}\t${fname}"; break; fi; size=$((size/1024)); done; done

2) As a function, instead of an alias - which allows you to pass paramters to du - source 'fire'
function duf {
du -sk "$@" | sort -n | perl -ne '($s,$f)=split(/\t/,$_,2);for(qw(K M G T)){if($s<1024){$x=($s<10?"%.1f":"%3d");printf("$x$_\t%s",$s,$f);last};$s/=1024}' } Combining together would probably make the best solution so far. function duf { du -sk "$@" | sort -n | while read size fname; do for unit in k M G T P E Z Y; do if [ $size -lt 1024 ]; then echo -e "${size}${unit}\t${fname}"; break; fi; size=$((size/1024)); done; done } If this has been useful to you, and would like to buy me a coffee (via paypal) please click here. May 13th, 2009 | Tags: Command Line, Computing, Linux, Linux tips | Category: Computing, Linux Command Line Tips | 15 comments 15 comments to Linux – disk usage (du) human readable AND sorted by size * Casper May 14th, 2009 at 8:16 am Thanks for this cool script. One caveat is to watch out to use this in some top-level folder, it can take a very long time to finish. (Wish we had file systems that maintained directory size somehow.) * Twitted by metoikos May 14th, 2009 at 9:42 am [...] This post was Twitted by metoikos – Real-url.org [...] * Curtis May 15th, 2009 at 2:38 am du -s * | sort -n | sed -Ee ’s/^[0-9]+./”/’ -e ’s/$/”/’ | xargs du -sh Perl-less implementation; a little extra effort for filenames with spaces. (Yours doesn’t have to worry about that, obviously.) * Michael Speer May 15th, 2009 at 3:11 am http://www.nabble.com/Human-readable-sort-td23223205.html Never discount simply fixing the underlying problem. * Alex Shinn May 15th, 2009 at 5:04 am That’s always bugged me as well! I’ve made a few changes, though, so that it produces the same formatted output as du -sh. Also, as a function it can take arguments: function duf { du -sk "$@" | sort -n | perl -ne '($s,$f)=split(/\t/,$_,2);for(qw(K M G T)){if($s<1024){$x=($s<10?"%.1f":"%3d");printf("$x$_\t%s",$s,$f);last};$s/=1024}' } * Chris May 15th, 2009 at 5:50 am @casper I don’t. I prefer not to pay an additional cost on every write, to speed up this far-less-frequent case. * Leonid Volnitsky May 15th, 2009 at 6:08 am Latest version of sort (part of coreutils) supports -h (correct sorting of M,k,G suffixes). * fire May 15th, 2009 at 7:02 am I use the following… you see it use ‘du’ two times, but this is not really slower, ’cause the operating system caches. # sorted du -hsc function duhs() { du -s $* | sort -n | cut -f 2- | while read a; do du -sh $a; done } * DVoita May 15th, 2009 at 7:09 am If you modify du -sk * to du -sk * .??* you can see hidden dot files as well. * chris May 15th, 2009 at 8:04 am Thanks to inataysia on reddit for a bash only version du -sk * | sort -n | while read size fname; do for unit in k M G T P E Z Y; do if [ $size -lt 1024 ]; then echo -e "${size}${unit}\t${fname}"; break; fi; size=$((size/1024)); done; done * Gordon Mohr May 18th, 2009 at 12:11 am Why not promote the ‘human-readability’ step to a standalone utility? Let’s call it ‘hu’ for ‘human units’. Hypothetically, it would convert any whitespace-delimited numbers found on stdin to human-readable units when echoing to stdout. (Optional arguments could limit this conversion to just certain fields or to alternate unit systems.) Then the solution would be: du -sb * | sort -n | hu * Michael Speer May 18th, 2009 at 3:37 pm Sat Jan 20 06:00:09 1996 Jim Meyering (——@na-net.ornl.gov) —snip— * du.c (main): New options –human-readable (-h) and –megabytes (-m). (human_readable): New function. From Larry McVoy (——@sgi.com). Ever since this patch was included in fileutils, system administrators have been frustrated by finding that while they could `du -h` they could not then `sort -h` the output. -h is not posix but is now solidly a part of the gnu coreutils du and ls commands. Including a switch for sort that respects the switch for du was not my invention. It has been argued a number of times on the developers mailing list. Mine was simply the straw which broke the camels back. The additional switch is consistent with the other tools, and merely augments the purpose of sort without creating a differing utility to it. Something of the functionality of `hu` may have been the appropriate fix in ‘96, but since the ‘96 -h switch is long set, adding a corresponding switch to sort seems only too appropriate. To `promote’ -h out of du, df and ls into a separate utility would break scripts of users that depend on it. * Josh May 18th, 2009 at 6:45 pm You can also set the BLOCK_SIZE environment variable to the value human-readable and all the GNU coreutils that report sizes will respect it. * Jason Sares May 19th, 2009 at 6:54 am my solution du -s * 2>/dev/null | sort -n | cut -f2 | xargs du -sh 2>/dev/null
*
Gordon Mohr
May 19th, 2009 at 10:46 pm

I like ‘-h’ too; it doesn’t have to go away for ‘hu’ to also exist and be useful in other contexts, or when people need a sort to precision hidden by ‘-h’ rounding.

Monday, November 2, 2009

How to Disable IPv6 in Fedora and CentOS

— SkyHi @ Monday, November 02, 2009
They say that by disabling IPv6 things get a bit smoother and faster regarding networking. I don’t really know if this is true, but I guess, if you’ve decided to disable this feature, you probably care to do it the Right Way™. As far as I know, trying to disable IPv6 through anaconda during the installation of Fedora or CentOS does not turn off the IPv6 functionality completely, but it just disables it for the configured network interface. This is not actually a problem, but, why should this network layer be enabled system-wide, if you do not use it at all? This small article assists you in disabling IPv6 in the latest Fedora and CentOS releases in an aggressive and unforgiving way.
Check if the module is loaded

IPv6 functionality is being made available to the system by the ipv6 kernel module. To check if this module is currently loaded in your system, issue the following command as root:

lsmod | grep ipv6

If you see ipv6 in its output, then the module is loaded.

Performing this check is absolutely not necessary. It is included in this article for completeness.
Disable IPv6

You can prevent a module from being inserted into the kernel by either blacklisting it or by completely disabling it.

In this case, since you will most probably turn off the IPv6 firewall (ip6tables) as well, it is highly recommended to completely disable the ipv6 module, to avoid any accidental loading of the IPv6 stack without any firewall protection at the same time.
How the module blacklist works

This information about blacklisting a kernel module exists here for educational purposes. It has been mentioned above that for ipv6 it is important to completely disable it.

From the modprobe.conf man page:

Modules can contain their own aliases: usually these are aliases describing the devices they support, such as “pci:123…”. These “internal” aliases can be overridden by normal “alias” keywords, but there are cases where two or more modules both support the same devices, or a module invalidly claims to support a device: the blacklist keyword indicates that all of that particular module’s internal aliases are to be ignored.

So, blacklist indicates that a module’s aliases should be ignored. But, what happens if an application requires to load that specific module or if root uses modprobe to load it on demand? Let’s test it…

To blacklist the module, simply save the following line in a file inside /etc/modprobe.d:

blacklist ipv6

Next, disable any services that use IPv6, eg ip6tables or any IPv6-enabled network interfaces and reboot (mandatory).

After you’ve logged-in again, try, for example, to load the ipv6 module with the modprobe command (as root):

[root@centos]# modprobe -v ipv6
insmod /lib/modules/2.6.18-53.1.14.el5/kernel/net/ipv6/ipv6.ko
[root@centos]# lsmod | grep v6
ipv6 251393 8

The blacklisted module has been loaded. This is what happens if it is needed by a system service, regardless of the fact that it has been blacklisted. In the case of ipv6 this could be a security risk, provided that the ipv6 firewall has been turned off but some network interfaces still use IPv6. So, frankly, it is suggested to read on how to disable the module more aggressively…
Completely disable the ipv6 module

To completely disable IPv6 in your system, all you have to do is save the following line in a file inside /etc/modprobe.d/.

install ipv6 /bin/true

The above line means: whenever the system needs to load the ipv6 kernel module, it is forced to execute the command true instead of actually loading the module. Since /bin/true, does absolutely nothing, the module never gets loaded.

Again, it is required to reboot for the changes to take effect.

It is obvious that this is an aggressive method to disable kernel modules, but it guarantees that the module never gets loaded.

This is the recommended way to disable IPv6.
Other Configuration Tasks

Since the IPv6 functionality has been disabled, you can disable the ip6tables service (IPv6 Firewall). Issue the following command as root:

chkconfig ip6tables off

It is also a good idea, since the ip6tables service has been turned off, to disable any IPv6-related functionality in the network interface configuration. Even if you do not do this, the IPv6 stack will not be initialized because the ipv6 module cannot be loaded. But, generally, you could set the following options to “no” inside your network interface scripts, for example: /etc/sysconfig/network-scripts/ifcfg-eth0

IPV6INIT=no
IPV6_AUTOCONF=no

Finally, In fedora 8 or newer you can safely remove the following option from the /etc/sysconfig/network file, if it exists:

NETWORKING_IPV6=no

Final Thoughts

Using the instructions above, you can completely disable IPv6 in your system. On the other hand, you should understand that IPv6 is not an evil thing… It exists in order to address certain issues. If you ever think about actually trying to configure and use it instead of just disabling it every time you install your Linux operating system, here is a good place to start…
The How to Disable IPv6 in Fedora and CentOS by George Notaras, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Terms and conditions beyond the scope of this license may be available at www.g-loaded.eu.

Reference: http://www.g-loaded.eu/2008/05/12/how-to-disable-ipv6-in-fedora-and-centos/


RedHat / Centos Disable IPv6 Networking

Our policy and network configuration does not requires IPv6 support in RHEL / CentOS / Fedora Linux. How do I prevent the kernel module from loading at boot time and disable IPv6 networking?

You can easily prevent the kernel module from loading by updating the following two files:

1. /etc/modprobe.conf - Kernel driver configuration file.
2. /etc/sysconfig/network - RHEL / CentOS networking configuration file.

/etc/modprobe.conf

Edit /etc/modprobe.conf, enter:
# vi /etc/modprobe.conf
Append the following line:

install ipv6 /bin/true

Save and close the file.
/etc/sysconfig/network

Edit /etc/sysconfig/network, enter:
# vi /etc/sysconfig/network
Update / add as follows:


NETWORKING_IPV6=no
IPV6INIT=no


Save and close the file. Restart networking service
# service network restart
# rmmod ipv6
Alternatively, simple reboot the box:
# reboot
Verify IPv6 is disabled, enter:
# lsmod | grep ipv6
# /sbin/ifconfig

Reference: http://www.cyberciti.biz/faq/redhat-centos-disable-ipv6-networking/



8. How do I disable IPv6?

* Edit /etc/sysconfig/network and set "NETWORKING_IPV6" to "no"
* Add the following to /etc/modprobe.conf :

alias ipv6 off
alias net-pf-10 off

*

Run chkconfig ip6tables off to disable the IPv6 firewall
* Reboot the system

Alternative (which might be easier and works on any release with /etc/modprobe.d):

echo "install ipv6 /bin/true" > /etc/modprobe.d/disable-ipv6

* With the 5.4 update symbol/ipv6 module dependency capabilities have been introduced; therefore, if IPv6 has been previously disabled as above an upgrade to the bonding driver in 5.4 will result in the bonding kernel module failing to load. For the module to load properly use instead:

echo "options ipv6 disable=1" > /etc/modprobe.d/disable-ipv6

Reference: http://wiki.centos.org/FAQ/CentOS5




How do I disable the IPv6 protocol in Red Hat Enterprise Linux?
Release Found: Red Hat Enterprise Linux 4 and later



Red Hat Enterprise Linux 4 and 5 enable Internet Protocol Version 6 (IPv6) by default. However, in certain situations, some users may find it desirable to disable IPv6 support.



Disabling IPv6 Support Red Hat Enterprise Linux 4



If the following line exists in the /etc/modprobe.conf file, remove it:



alias net-pf-10 ipv6



Add the following line to the /etc/modprobe.conf file:



alias net-pf-10 off



Reboot the system to disable IPv6 support.



Re-enabling IPv6 Support Red Hat Enterprise Linux 4



Remove the following line from the /etc/modprobe.conf file.



alias net-pf-10 off



You must reboot the system to activate IPv6 support.


Disabling IPv6 Support Red Hat Enterprise Linux 5



If the following line exists in the /etc/modprobe.conf file, remove it:



alias net-pf-10 ipv6



Add the following line to the /etc/modprobe.conf file:



alias net-pf-10 off



In versions of Red Hat Enterprise Linux before 5.4, add the following line to the /etc/modprobe.conf file:



alias ipv6 off



In Red Hat Enterprise Linux 5.4 and later, add the following line to the /etc/modprobe.conf file:



options ipv6 disable=1



To prevent errors during the network initscript start routine, change the NETWORKING_IPV6 parameter in the /etc/sysconfig/network file to the following:



NETWORKING_IPV6=no



For completeness, it is a good idea to configure the ip6tables service not to start at boot by issuing the following command:



chkconfig ip6tables off



Once both the alias net-pf-10 off and alias ipv6 off lines are present in the /etc/modprobe.conf file and NETWORKING_IPV6=no is set in the /etc/sysconfig/network file, reboot the system to disable IPv6 support.



Re-enabling IPv6 Support Red Hat Enterprise Linux 5



To re-enable IPv6 on Red Hat Enterprise Linux 5 systems, remove the following lines from the /etc/modprobe.conf file:



alias net-pf-10 off

alias ipv6 off



Set the following parameter in the /etc/sysconfig/network file:



NETWORKING_IPV6=yes



Re-enable ipv6tables by issuing the following command:



chkconfig ip6tables on



You must reboot the system to activate IPv6 support.

Reference: http://kbase.redhat.com/faq/docs/DOC-8711