一、NAT模式环境设定
1.VS主机中
root@vsnode \~\]# vmset.sh eth0 172.25.254.100 vsnode \[root@vsnode \~\]# vmset.sh eth1 192.168.0.100 vsnode noroute ### **2.RS1** 设定网络 \[root@RS1 \~\]# vmset.sh eth0 192.168.0.20 RS1 noroute \[root@RS1 \~\]# nmcli connection modify eth0 ipv4.gateway 192.168.0.100 \[root@RS1 \~\]# nmcli connection reload \[root@RS1 \~\]# nmcli connection up eth0 \[root@RS1 \~\]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.0.100 0.0.0.0 UG 100 0 0 eth0 192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0 设定访问业务真实数据 \[root@RS1 \~\]# dnf install httpd -y \[root@RS1 \~\]# systemctl enable --now httpd \[root@RS1 \~\]# echo RS1 - 192.168.0.20 \> /var/www/html/index.html ### **3.RS2** #设定网络 \[root@RS1 \~\]# vmset.sh eth0 192.168.0.30 RS1 noroute \[root@RS1 \~\]# nmcli connection modify eth0 ipv4.gateway 192.168.0.100 \[root@RS1 \~\]# nmcli connection reload \[root@RS1 \~\]# nmcli connection up eth0 \[root@RS1 \~\]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.0.100 0.0.0.0 UG 100 0 0 eth0 192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0 设定访问业务真实数据 \[root@RS1 \~\]# dnf install httpd -y \[root@RS1 \~\]# systemctl enable --now httpd \[root@RS1 \~\]# echo RS2 - 192.168.0.30 \> /var/www/html/index.html ### **4.在vs主机中测试环境** \[root@vsnode \~\]# curl 192.168.0.20 RS1 - 192.168.0.20 \[root@vsnode \~\]# curl 192.168.0.30 RS2 - 192.168.0.30  ## 二、DR模式实验过程  ### 环境设定方式 #### 1.在路由器中 \[root@router \~\]# systemctl disable --now ipvsadm.service Removed "/etc/systemd/system/multi-user.target.wants/ipvsadm.service". \[root@router \~\]# ipvsadm -C \[root@router \~\]# vmset.sh eth0 172.25.254.100 vsnode \[root@router \~\]# vmset.sh eth1 192.168.0.100 vsnode noroute、 设定内核路由功能 \[root@router \~\]# echo net.ipv4.ip_forward=1 \>\> /etc/sysctl.conf \[root@router \~\]# sysctl -p net.ipv4.ip_forward = 1 数据转发策略 \[root@router \~\]# iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to-source 192.168.0.100 \[root@vsnode \~\]# iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 172.25.254.100 #### 2.vsnode 调度器 \[root@vsnode \~\]# vmset.sh eth0 192.168.0.50 vsnode norouter \[root@vsnode \~\]# vim /etc/NetworkManager/system-connections/eth0.nmconnection \[connection
id=eth0
type=ethernet
interface-name=eth0
ipv4
method=manual
address1==192.168.0.50/24,192.168.0.100
root@vsnode \~\]# cd /etc/NetworkManager/system-connections/ \[root@vsnode system-connections\]# cp -p eth0.nmconnection lo.nmconnection \[root@vsnode system-connections\]# vim lo.nmconnection \[connection
id=lo
type=loopback
interface-name=lo
ipv4
method=manual
address1==127.0.0.1/8
address2=192.168.0.200/32
root@RS1 system-connections\]# nmcli connection reload
\[root@RS1 system-connections\]# nmcli connection up eth0
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/7)
\[root@RS1 system-connections\]# nmcli connection up lo
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/8)
#### 3.检测
\[root@vsnode system-connections\]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.100 0.0.0.0 UG 100 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0

#### 4.客户端
\[root@client \~\]# vmset.sh eth0 172.25.254.99 client norouter
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/4)
2: eth0: \
id=eth0
type=ethernet
interface-name=eth0
ipv4
method=manual
address1=172.25.254.99/24,172.25.254.100
dns=8.8.8.8;
root@client \~\]# nmcli connection reload \[root@client \~\]# nmcli connection up eth0 连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/5) \[root@client \~\]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 172.25.254.100 0.0.0.0 UG 100 0 0 eth0 172.25.254.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0 #### 检测 \[root@client \~\]# ping 192.168.0.200 PING 192.168.0.200 (192.168.0.200) 56(84) 比特的数据。 64 比特,来自 192.168.0.200: icmp_seq=1 ttl=128 时间=1.08 毫秒 #### 5.RS1 \[root@RS1 \~\]# vmset.sh eth0 192.168.0.10 RS1 noroute \[root@RS1 \~\]# nmcli connection modify eth0 ipv4.gateway 192.168.0.100 \[root@RS1 \~\]# nmcli connection reload \[root@RS1 \~\]# nmcli connection up eth0 \[root@RS1 \~\]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.0.100 0.0.0.0 UG 100 0 0 eth0 192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0 在lo上设定vip \[root@RS1 \~\]# cd /etc/NetworkManager/system-connections/ \[root@RS1 system-connections\]# cp -p eth0.nmconnection lo.nmconnection \[root@RS1 system-connections\]# vim lo.nmconnection \[connection
id=lo
type=loopback
interface-name=lo
ethernet
ipv4
address1=127.0.0.1/8
address2=192.168.0.200/32
method=manual
root@RS1 system-connections\]# nmcli connection reload
\[root@RS1 system-connections\]# nmcli connection up lo
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/6)
\[root@RS1 system-connections\]# ip a
1: lo: \
id=lo
type=loopback
interface-name=lo
ethernet
ipv4
address1=127.0.0.1/8
address2=192.168.0.200/32
method=manual
root@RS2 system-connections\]# nmcli connection reload
\[root@RS2 system-connections\]# nmcli connection up lo
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/6)
\[root@RS2 system-connections\]# ip a
1: lo: \