当前位置: 首页 > news >正文

LVS——nat模式

一、搭建nat模式下LVS的实验环境

1.创建四台虚拟机

client——客户端:192.168.134.111/24(nat模式)

LVS——调度器【双网卡】:192.168.134.112/24(nat模式)、172.25.254.111/24(仅主机模式)

RS1——服务器:172.25.254.10(仅主机模式)

RS2——服务器:172.25.254.20(仅主机模式)

2.给两台测试主机下载httpd服务
[root@RS1 ~]# dnf install httpd -y
[root@RS1 ~]# systemctl enable --now httpd[root@RS2 ~]#  dnf install httpd -y
[root@RS2 ~]# systemctl enable --now httpd(注:下载完httpd服务后别忘了启动该服务)
使用:
[root@LVS ~]# ss -tulpn | grep :80
tcp   LISTEN 0      511                *:80              *:*    users:(("httpd",               pid=30465,fd=4),("httpd",pid=30464,fd=4),("httpd",pid=30463,fd=4),("httpd",pid=3               0461,fd=4))可以通过端口查看该服务是否开启
3.关闭RS1、RS2虚拟机的防火墙
[root@RS1 ~]# systemctl disable --now firewalld
Removed "/etc/systemd/system/multi-user.target.wants/firewalld.service".
Removed "/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service".[root@RS2 ~]# systemctl disable --now firewalld
Removed "/etc/systemd/system/multi-user.target.wants/firewalld.service".
Removed "/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service".
记得查看防火墙状态:
systemctl status firewalld
4.给RS1、RS2两台服务器开启web服务
[root@RS1 ~]# mkdir -p /var/www/html
[root@RS1 ~]# echo "RS1 -- 172.25.254.10" > /var/www/html/index.html[root@RS2 ~]# mkdir -p /var/www/html
[root@RS2 ~]# echo "RS2 -- 172.25.254.20" > /var/www/html/index.html
5.保证LVS能访问到RS1、RS2两台服务器的web服务
[root@LVS ~]# curl 172.25.254.10
RS1 -- 172.25.254.10
[root@LVS ~]# curl 172.25.254.20
RS2 -- 172.25.254.20
6.修改LVS内核参数,打开内核路由功能,使系统内部不同网段网络可达(IP转发)
[root@LVS ~]# sysctl -a | grep ip_forward
net.ipv4.ip_forward = 0
net.ipv4.ip_forward_update_priority = 1
net.ipv4.ip_forward_use_pmtu = 0
[root@LVS ~]# vim /etc/sysctl.conf
[root@LVS ~]# sysctl -p
net.ipv4.ip_forward = 1
7.接着为调度器LVS安装ipvsadm
[root@LVS ~]# dnf install ipvsadm -y

二、如果要使客户端到RS1、RS2这几台虚拟机可以互相通信,那么还需修改网关

RS1:
[connection]
id=eth0
type=ethernet
interface-name=eth0[ipv4]
method=manual
address1=172.25.254.10/24,172.25.254.111
dns=8.8.8.8RS2:
[connection]
id=eth0
type=ethernet
interface-name=eth0[ipv4]
method=manual
address1=172.25.254.20/24,172.25.254.111
dns=8.8.8.8记得修改完之后要
nmcli connection reload 
nmcli connection up eth0

效果为:

  

http://www.lryc.cn/news/593743.html

相关文章:

  • 分立元件线性稳压器12V转5VMultisim仿真
  • 最终分配算法【论文材料】
  • 力扣24:两两交换链表中的节点
  • [FFmpeg] 输入输出访问 | 管道系统 | AVIOContext 与 URLProtocol | 门面模式
  • 外观设计模式
  • 零基础学习性能测试第二章-linux服务器监控:CPU监控
  • Redis字符串操作指南:从入门到实战应用
  • SQLShift:一款异构数据库存储过程迁移工具
  • c++ 基本语法易错与技巧总结
  • 模型的评估与选择
  • 【52】MFC入门到精通——(CComboBox)下拉框选项顺序与初始化不一致,默认显示项也不一致
  • yolov8-pos/yolov11-pos openvino C++部署
  • bash方式启动模型训练
  • OpenCV特征点提取算法orb、surf、sift对比
  • 相机参数的格式与作用
  • 算法基础知识总结
  • MYSQL 第一次作业
  • 量子计算与AI融合的技术突破与实践路径
  • scalelsd 笔记 线段识别 本地部署 模型架构
  • 【面试题】大厂高压面经实录丨第三期
  • SpringBoot服装推荐系统实战
  • 石子问题(区间dp)
  • 泛型机制详解
  • Java中缓存的使用浅讲
  • 从代码学习深度强化学习 - SAC PyTorch版
  • openmv小车追小球
  • PCA主成分分析
  • xss-labs1-8题
  • lvs笔记
  • JAVA高级第六章 输入和输出处理(一)