一、准备工作

yum groupinstall "Development Tools" -y
yum install ncurses-devel -y # make *config
yum install qt-devel -y # X 环境需要
yum install wget -y
yum install hmaccalc zlib-devel binutils-devel elfutils-libelf-devel -y # 编译内核需要

二、下载kernel

# 官方 https://www.kernel.org/pub/linux/kernel/v3.x/
# 镜像 http://mirror.bjtu.edu.cn/kernel/linux/kernel/v3.x/
wget -c https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.19.3.tar.xz

三、编译/安装Kernel

tar jxvf linux-3.19.3.tar.xz
cd linux-3.19.3
make mrproper
make menuconfig #配置要编译的内核模块

找到以下选中选项并选中networking support → networking options → network packet filtering framework(netfilter)
(1)Core netfilter configuration
勾中"Netfilter connection tracking support" -m state相关模块是依赖它的,不选则没有。
将netbios name service protocal support(new) 编译成模块,不然后面升级iptables后启动时会出错
勾中"Netfilter Xtables support (required for ip_tables)"
(2)IP: Netfilter Configuration
将 "IPv4 connection tracking support (require for NAT)" 编译成模块。
勾中IP tables support (required for filtering/masq/NAT) 。
将 "Full NAT" 下的 "MASQUERADE target support" 和 "REDIRECT target support" 编译成模块

make clean #确保所有东西均保持最新状态.
make bzImage #生成内核文件
make modules #编译模块
make modules_install #安装模块
make install #安装

四、编辑 GRUB引导菜单 vi /etc/grub.conf 启用新内核,最后重启

摘自:http://down.chinaz.com/server/201202/1598_1.htm