第二十六天

NAT服务配置
1.关闭防火墙和selinux 
[root@2 ~]# setenforce 0
[root@2 ~]# vim /etc/selinux/config
[root@2 ~]# systemctl stop firewalld
[root@2 ~]# systemctl disable firewalld
2.安装nginx (web1和web2)
[root@2 ~]# yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel    #安装依赖包
[root@2 ~]# yum -y install nginx
3.重定向启动nginx (web1和web2)
echo “web01” > /usr/local/nginx/html/index.html(192.168.20.144)
echo “web02” >  /usr/local/nginx/html/index.html (192.168.20.137)
网页连接测试
4.nat主机(两块网卡192.168.20.146/147)
[root@nat ~]# echo "nameserver 192.168.20.149" > /etc/resolv.conf
在NAT调度器配置两个网卡和两个IP地址
C:\Users\89765>ping 192.168.8.167
正在 Ping 192.168.8.167 具有 32 字节的数据:
来自 192.168.8.167 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.8.167 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.8.167 的回复: 字节=32 时间<1ms TTL=64
192.168.8.167 的 Ping 统计信息:
    数据包: 已发送 = 3,已接收 = 3,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 0ms,最长 = 0ms,平均 = 0ms
C:\Users\89765>ping 192.168.8.169
正在 Ping 192.168.8.169 具有 32 字节的数据:
来自 192.168.8.169 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.8.169 的回复: 字节=32 时间<1ms TTL=64
192.168.8.169 的 Ping 统计信息:
    数据包: 已发送 = 2,已接收 = 2,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 0ms,最长 = 0ms,平均 = 0ms
5.dns主机(192.168.20.148)
[root@dns ~]# yum -y install bind
[root@dns ~]# vim /etc/named.conf      #修改主配置文件

[root@dns ~]# vim /etc/named.rfc1912.zones    #修改zones文件

[root@dns etc]# cd /var/named/
[root@dns named]# cp named.localhost el.zzj.zone
[root@dns named]# vim el.zzj.zone       #修改zone文件

#启动服务
[root@dns ~]# vim /etc/resolv.conf   #清空里面的内容
[root@dns ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33   #更改内容


#client主机IP
[root@dns ~]# systemctl restart network    #重启网络
[root@dns ~]# ping 192.168.20.149    #

6.client主机(客户机)
测试
LVS负载均衡
1.时间服务器
[root@dns ~]# yum -y install ntpdate.x86_64  (dns或nat上都行)
[root@lvs ~]# crontab -e
* 2 * * * /usr/sbin/ntpdata cn.ntp.org.cn
[root@lvs ~]# yum -y install ntp
[root@lvs ~]# systemctl start ntpd
[root@lvs ~]# systemctl enable ntpd
2.ntp服务器
[root@dns ~]# yum -y install ntp
[root@dns ~]# systemctl start ntpd  #启动
[root@dns ~]# systemctl enable ntpd  #开机自启
[root@dns ~]# cd /var/named/
[root@dns named]# crontab -e
* * * * * /usr/sbin/ntpdate 192.168.20.148   #IP为配置时间服务器的IP
3.配置规则
[root@lvs ~]# yum -y install ipvsadm.x86_64
[root@lvs ~]# ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
[root@lvs ~]# ipvsadm -C   #清空以往规则
[root@lvs ~]# ipvsadm -L   #
[root@lvs ~]# ipvsadm -A -t 192.168.8.167:80 -s rr  #添加轮询 -A是对外网的
[root@lvs ~]# ipvsadm -L -n
TCP  192.168.8.167:80 rr
[root@lvs ~]# ipvsadm -a -t 192.168.8.169:80 -r 192.168.8.166:80 -m   #-a 对内网 后面是web01
[root@lvs ~]# ipvsadm -a -t 192.168.8.169:80 -r 192.168.8.168:80 -m

  • 7
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值