linux下lvs的fullnat模式

标签: 内核编译  fullnat

Lvs的fullnat模式:

编译内核之前,安装keepalived和ipvsadm
(若有问题请参考https://blog.csdn.net/qq_38622229/article/details/81324744)

关闭所有虚拟机,将server1的内存大小设置为最小2048
server1中
src:未编译的原码,需要进行编译
在官网上下载kernel-2.6.32-220.23.1.el6.src.rpm和Lvs-fullnat-synproxy.tar.gz

yum install -y rpm-build
rpm -ivh kernel-2.6.32-220.23.1.el6.src.rpm
cd rpmbuild/SPECS
rpmbuild -bp kernel.spec(解决所有依赖性)

这里写图片描述

yum install -y redhat-rpm-config patchutils xmlto asciidoc elfutils-libelf-devel binutils-devel newt-devel python-devel perl-ExtUtils-Embed hmaccalc
安装之后若没有在官网上下载所需的安装包
yum install -y asciidoc-8.4.5-4.1.el6.noarch.rpm newt-devel-0.52.11-3.el6.x86_64.rpm  slang-devel-2.2.1-1.el6.x86_64.rpm
rpmbuild -bp kernel.spec(需要敲击键盘产生随机数,也可以rngd -r /dev/urandom(若命令没有,则yum provides */rngd安装) )
tar zxf Lvs-fullnat-synproxy.tar.gz
cd lvs-fullnat-synproxy/
cp lvs-2.6.32-220.23.1.el6.patch /root/rpmbuild/BUILD/kernel-2.6.32-220.23.1.el6/linux-2.6.32-220.23.1.el6.x86_64/
Vim /root/rpmbuild/BUILD/kernel-2.6.32-220.23.1.el6/linux-2.6.32-220.23.1.el6.x86_64/Makefile (加上文件版本号)
make #编译
make modules_install # 安装模块
make install
vim /boot/grub/grub.conf
default=0
reboot  # 若reboot出错,恭喜你再来一次

重新编译keepalived,以适应内核版本

tar zxf lvs-tools.tar.gz
cd tools/keepalived
./configure --with-kernel-dir="/lib/modules/`uname -r`/build";
make;
make install;

重新编译ipvsadm

cd tools/ipvsadm
make;
make install

这里写图片描述
若ipvsadm -ln出现fullnat之后则内核、keepalived、ipvsadm编译成功。

原文链接:加载失败,请重新获取