当前位置: 首页 > 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.dtcms.com/a/287206.html

相关文章:

  • 【ArcGIS技巧】最近分享的GIS插件总结与优化
  • 实战分享:Web3 前端开发Defi项目
  • 【设计模式C#】外观模式(用于解决客户端对系统的许多类进行频繁沟通)
  • 【Unity编辑器开发GUI.Window】
  • 企业运维实战:Jenkins 依赖 JDK21 与应用需 JDK1.8 共存方案(含流水线配置)
  • 软件工程:可行性分析的任务及报告
  • 【NLP舆情分析】基于python微博舆情分析可视化系统(flask+pandas+echarts) 视频教程 - 基于wordcloud库实现词云图
  • 使用nvm安装node、npm、pnpm以及编译项目教程
  • 告别项目混乱:基于 pnpm + Turborepo 的现代化 Monorepo 工程化最佳实践
  • 【音视频协议篇】RTSP系列
  • gitlab+jenkins
  • 综合实验--eNSP实验
  • k8s 基本架构
  • Flowable31动态表单-----------------------终章
  • AI编程工具对比:Cursor、GitHub Copilot与Claude Code
  • bws-rs:Rust 编写的 S3 协议网关框架,支持灵活后端接入
  • 【Linux】AKHQ实现kafka可视化
  • 电力载波通信技术全景解析:从历史演进到智能电网创新应用
  • 【Linux服务器】-MySQL数据库参数调优
  • 打造高效订单处理!ZKmall开源商城的统一履约中心架构解析
  • 本地部署开源的 AI 驱动的搜索引擎 Perplexica 并实现外部访问
  • 【黑马SpringCloud微服务开发与实战】(三)微服务01
  • 快速上手AI整合包!GPT-SoVITS-v2打包教程,解锁AIStarter应用市场潜力
  • freertos任务调度关键函数理解
  • 笔试强训——第一周
  • 标准文件和系统文件I/O
  • 鸿蒙与web混合开发双向通信
  • 云服务器磁盘IO性能优化的测试与配置方法
  • docker|Linux|以centos基础镜像为基础制作nmap专用镜像(镜像瘦身计划)
  • SQL基础操作指南:约束、表设计与复杂查询