13. nginx,lvs之一

摘要:php

一、詳細描述常見nginx經常使用模塊和模塊的使用示例 
二、簡述Linux集羣類型、系統擴展方式及調度方法 
三、簡述lvs四種集羣有點及使用場景 
四、描述LVS-NAT、LVS-DR的工做原理並實現配置html

 

一、詳細描述常見nginx經常使用模塊和模塊的使用示例 前端

 

Nginx的代碼由一個核心和一系列的模塊組成。linux

核心(core functionality)主要用於提供全局應用的基本功能,建立必要的運行時環境及確保不一樣模塊之間平滑地進行交互等,對應於配置文件的main段和event段。核心涉及的指令官方文檔:http://nginx.org/en/docs/ngx_core_module.htmlnginx

還有不少功能都經過模塊實現,nginx是高度模塊化程序。如web相關的功能模塊有"ngx_http_*_module",和mail相關的功能模塊有"ngx_mail_*_module",和tcp代理、負載均衡相關的功能模塊有"ngx_stream_*_module",這些類別的模塊中又分爲不少類別的模塊,如http類別的模塊中有基本核心模塊、事件類模塊、緩存類模塊、SSL相關模塊、負載均衡類模塊upstream等等。web

如下是http功能模塊類中常見的模塊。算法

http類模塊名 模塊功能說明
ngx_http_core_module http核心模塊,對應配置文件中的http段,包含不少指令,如location指令
ngx_http_access_module 訪問控制模塊,控制網站用戶對nginx的訪問,對應於配置文件中的allow和deny等指令
ngx_http_auth_basic_module 經過用戶名和密碼認證的訪問控制,如訪問站點時須要數據用戶名和密碼,指令包括auth_basic和auth_basic_user_file
ngx_http_charset_module 設置網頁顯示字符集。指令之一爲charset,如charset utf-8
ngx_http_fastcgi_module fastcgi模塊,和動態應用相關。該模塊下有很是多的子模塊。
ngx_http_flv_module 支持flv視頻流的模塊,如邊下邊播
ngx_http_mp4_module 同flv模塊
ngx_http_gzip_module 壓縮模塊,用來壓縮nginx返回的響應報文。通常只壓縮純文本內容,由於壓縮比例很是大,而圖片等不會去壓縮
ngx_http_image_filter_module 和圖片裁剪、縮略圖相關模塊,須要安裝gd-devel才能編譯該模塊
ngx_http_index_module 定義將要被做爲默認主頁的文件,對應指令爲index。"index index.html,index.php"
ngx_http_autoindex_module 當index指令指定的主頁文件不存在時,交給autoindex指令,將自動列出目錄中的文件autoindex {on/off}  
ngx_http_log_module 和訪問日誌相關的模塊,指令包括log_format和access_log
ngx_http_memcached_module 和memcached相關的模塊,用於從memcached服務器中獲取相應響應數據
ngx_http_proxy_module 和代理相關,容許傳送請求到其它服務器
ngx_http_realip_module 當nginx在反向代理的後端提供服務時,獲取到真正的客戶端地址,不然獲取的是反向代理的IP地址
ngx_http_referer_module 實現防盜鏈功能的模塊
ngx_http_rewrite_module 和URL地址重寫相關的模塊,須要安裝pcre-devel才能編譯安裝該模塊
ngx_http_scgi_module simple cgi,是cgi的替代品,和fastcgi相似,但更簡單
ngx_http_ssl_module 提供ssl功能的模塊,即實現HTTPS
ngx_http_stub_status_module 獲取nginx運行狀態信息
ngx_http_upstream 和負載均衡相關模塊

下面只介紹三個模塊:vim

ngx_http_access module          實現基於IP地址的訪問控制後端

ngx_http_auth_basic_module   實現基於用戶的訪問控制,使用basic認證機制認證緩存

ngx_http_stub_status_module   用於輸出nginx的基本狀態信息

 

1.1  在服務器上配置/etc/nginx/conf.d/vhost.conf文件

[root@bogon conf.d]# cat vhost.conf
server {
listen 80;
server_name www.danlee.io;
root /data/nginx/vhost;

location / {
deny 192.168.1.11;
allow all;
}

location ~* ^/(admin|login) {
auth_basic "admin area or login url";
auth_basic_user_file /etc/nginx/.ngxpasswd;
}

location /ngxstatus {
stub_status;
}
}

[root@bogon conf.d]# tree /data
/data
└── nginx
└── vhost
├── admin
│   └── index.html
└── index.html

3 directories, 2 files
[root@bogon conf.d]# cat /data/nginx/vhost/index.html
<h1>www.danlee.io, mainpage</h1>
[root@bogon conf.d]# cat /data/nginx/vhost/admin/index.html
<h1>Admin area</h1>

[root@bogon conf.d]#htpasswd -c -m /etc/nginx/.ngxpasswd tom

[root@bogon conf.d]#htpasswd -m /etc/nginx/.ngxpasswd jerry

[root@bogon conf.d]# cat /etc/nginx/.ngxpasswd
tom:$apr1$nYfn6I3F$NmKnqGEwLtOySxkNljc9P1
jerry:$apr1$2sa3N.Kg$Ju1tJ8IcMX4lmgS8qzOKo.

 

[root@bogon conf.d]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@bogon conf.d]# nginx -s reload

 

 1.2 在兩個客戶端驗證

首先在兩個客戶端上都編輯/etc/hosts文件添加服務器IP and server name.

192.168.1.21   www.danlee.io

客戶端192.168.1.22上 驗證:

 1 [root@bogon ~]# curl http://www.danlee.io/ngxstatus  2 Active connections: 1  3 server accepts handled requests  4 7 7 11  5 Reading: 0 Writing: 1 Waiting: 0  6 [root@bogon ~]# curl http://www.danlee.io  7 <h1>www.danlee.io, mainpage</h1>  8 [root@bogon ~]# curl http://www.danlee.io/index.html  9 <h1>www.danlee.io, mainpage</h1> 10 [root@bogon ~]# cat /etc/hosts 11 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 12 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 13 192.168.1.21 www.danlee.io

 

 

客戶端192.168.1.11上 驗證:

 1 [root@localhost ~]# curl http://www.danlee.io  2 <html>  3 <head><title>403 Forbidden</title></head>  4 <body bgcolor="white">  5 <center><h1>403 Forbidden</h1></center>  6 <hr><center>nginx/1.12.2</center>  7 </body>  8 </html>  9 [root@localhost ~]# curl http://www.danlee.io/ngxstatus 10 Active connections: 1 11 server accepts handled requests 12 14 14 18 13 Reading: 0 Writing: 1 Waiting: 0 14 [root@localhost ~]# curl http://www.danlee.io/admin 15 <html> 16 <head><title>401 Authorization Required</title></head> 17 <body bgcolor="white"> 18 <center><h1>401 Authorization Required</h1></center> 19 <hr><center>nginx/1.12.2</center> 20 </body> 21 </html> 22 [root@localhost ~]# 

 

 備註: 由於沒有在服務器端對ngxstatus模塊配置驗證,此客戶端依然能夠訪問該頁面數據。

 


二、簡述Linux集羣類型、系統擴展方式及調度方法

Linux Cluster類型:
LB:Load Balancing,負載均衡;
HA:High Availiablity,高可用;
A=MTBF/(MTBF+MTTR)
(0,1):90%, 95%, 99%, 99.5%, 99.9%, 99.99%, 99.999%, 99.9999%
HP:High Performance,高性能;

 

系統擴展方式:
Scale UP:向上擴展
Scale Out:向外擴展

 

ipvs scheduler:
根據其調度時是否考慮各RS當前的負載狀態,可分爲靜態方法和動態方法兩種:

靜態方法:僅根據算法自己進行調度;
RR:roundrobin,輪詢;
WRR:Weighted RR,加權輪詢;
SH:Source Hashing,實現session sticky,源IP地址hash;未來自於同一個IP地址的請求始終發往第一次挑中的RS,從而實現會話綁定;
DH:Destination Hashing;目標地址哈希,將發往同一個目標地址的請求始終轉發至第一次挑中的RS,典型使用場景是正向代理緩存場景中的負載均衡;

動態方法:主要根據每RS當前的負載狀態及調度算法進行調度;
Overhead=負載值

LC:least connections
Overhead=activeconns*256+inactiveconns
WLC:Weighted LC
Overhead=(activeconns*256+inactiveconns)/weight
SED:Shortest Expection Delay
Overhead=(activeconns+1)*256/weight
NQ:Never Queue

LBLC:Locality-Based LC,動態的DH算法;
LBLCR:LBLC with Replication,帶複製功能的LBLC;


三、簡述lvs四種集羣特色及使用場景 

 

lvs集羣的類型:
lvs-nat:修改請求報文的目標IP;多目標IP的DNAT;
lvs-dr:操縱封裝新的MAC地址;
lvs-tun:在原請求IP報文以外新加一個IP首部;
lvs-fullnat:修改請求報文的源和目標IP;

 

lvs-nat:
多目標IP的DNAT,經過將請求報文中的目標地址和目標端口修改成某挑出的RS的RIP和PORT實現轉發;

(1)RIP和DIP必須在同一個IP網絡,且應該使用私網地址;RS的網關要指向DIP; (DIP是內網,VIP是外網?)
(2)請求報文和響應報文都必須經由Director轉發;Director易於成爲系統瓶頸;
(3)支持端口映射,可修改請求報文的目標PORT;
(4)vs必須是Linux系統,rs能夠是任意系統;

lvs-dr:
Direct Routing,直接路由;
經過爲請求報文從新封裝一個MAC首部進行轉發,源MAC是DIP所在的接口的MAC,
目標MAC是某挑選出的RS的RIP所在接口的MAC地址;源IP/PORT,以及目標IP/PORT均保持不變;

Director和各RS都得配置使用VIP;
(1) 確保前端路由器將目標IP爲VIP的請求報文發往Director:
(a) 在前端網關作靜態綁定;
(b) 在RS上使用arptables;
(c) 在RS上修改內核參數以限制arp通告及應答級別;
arp_announce
arp_ignore
(2) RS的RIP能夠使用私網地址,也能夠是公網地址;RIP與DIP在同一IP網絡;RIP的網關不能指向DIP,以確保響應報文不會經由Director;
(3) RS跟Director要在同一個物理網絡;
(4) 請求報文要經由Director,但響應不能經由Director,而是由RS直接發往Client;
(5) 不支持端口映射;

 

 

lvs-tun:
轉發方式:不修改請求報文的IP首部(源IP爲CIP,目標IP爲VIP),而是在原IP報文以外再封裝一個IP首部(源IP是DIP,目標IP是RIP),
將報文發往挑選出的目標RS;RS直接響應給客戶端(源IP是VIP,目標IP是CIP);

(1) DIP, VIP, RIP都應該是公網地址;
(2) RS的網關不能,也不可能指向DIP;
(3) 請求報文要經由Director,但響應不能經由Director;
(4) 不支持端口映射;
(5) RS的OS得支持隧道功能;

lvs-fullnat:
經過同時修改請求報文的源IP地址和目標IP地址進行轉發;
CIP <--> DIP
VIP <--> RIP

(1) VIP是公網地址,RIP和DIP是私網地址,且一般不在同一IP網絡;所以,RIP的網關通常不會指向DIP;
(2) RS收到的請求報文源地址是DIP,所以,只能響應給DIP;但Director還要將其發往Client;
(3) 請求和響應報文都經由Director;
(4) 支持端口映射;

注意:此類型默認不支持;


總結:
lvs-nat, lvs-fullnat:請求和響應報文都經由Director;
lvs-nat:RIP的網關要指向DIP;
lvs-fullnat:RIP和DIP未必在同一IP網絡,但要能通訊;
lvs-dr, lvs-tun:請求報文要經由Director,但響應報文由RS直接發往Client;
lvs-dr:經過封裝新的MAC首部實現,經過MAC網絡轉發;
lvs-tun:經過在原IP報文以外封裝新的IP首部實現轉發,支持遠距離通訊;


四、描述LVS-NAT、LVS-DR的工做原理並實現配置

lvs-nat:
多目標IP的DNAT,經過將請求報文中的目標地址和目標端口修改成某挑出的RS的RIP和PORT實現轉發;
(1)RIP和DIP必須在同一個IP網絡,且應該使用私網地址;RS的網關要指向DIP;
(2)請求報文和響應報文都必須經由Director轉發;Director易於成爲系統瓶頸;
(3)支持端口映射,可修改請求報文的目標PORT;
(4)vs必須是Linux系統,rs能夠是任意系統;

 

1)準備:
1. 關閉selinux, 清空iptables, 同步dr, rs1, rs2上的時間
2. 在rs1, rs2上分別安裝nginx, telnet-server
在dr上安裝nginx, ipvsadm
3. dr調度器:
                   DIP: 192.168.1.6
                   VIP: 127.16.1.7
rs1服務器1 RIP1:127.16.1.8
rs2服務器2 RIP2: 127.16.1.9
若是是dr, rs在同一臺電腦上的虛擬機上,dip, rip都須要改成僅主機模式vmnet1。調整網絡前先安裝必要的軟件包。
VIP, RIP須要使用私網地址。
Director要打開核心轉發功能sysctl -w net.ipv4.ip_forward=1
如何在虛擬機中添加一個新的網卡,能夠參考(實際步驟會不相同)https://blog.csdn.net/qq_21383435/article/details/51126577

2)配置:

在RS1上:

# vim /usr/share/nginx/html/test1.html        添加內容<h1>RS1, ####172.16.1.8</h1>
# systemctl start nginx.service

# ss -tnl                       檢查80端口是否打開

在RS2上:

# vim /usr/share/nginx/html/test1.html        添加內容<h1>RS2, ####172.16.1.9</h1>

# systemctl start nginx.service

# ss -tnl                       檢查80端口是否打開

在DR上:

[root@bogon ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.6 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::fb51:8e3:4aa5:5358 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:37:ff:fd txqueuelen 1000 (Ethernet)
RX packets 7072 bytes 5524007 (5.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3960 bytes 354712 (346.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.1.7 netmask 255.255.0.0 broadcast 172.16.255.255
inet6 fe80::20c:29ff:fe37:ff07 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:37:ff:07 txqueuelen 1000 (Ethernet)
RX packets 717 bytes 85009 (83.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 133 bytes 15590 (15.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

 

[root@bogon ~]# ipvsadm -A -t 192.168.1.6:80 -s rr           #注意此處爲VIP

[root@bogon ~]# ipvsadm -a -t 192.168.1.6:80 -r 172.16.1.9 -m
[root@bogon ~]# ipvsadm -a -t 192.168.1.6:80 -r 172.16.1.8 -m
[root@bogon ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.1.6:80 rr
-> 172.16.1.8:80 Masq 1 0 0
-> 172.16.1.9:80 Masq 1 0 0

在客戶端上:

[root@stephen ~]# curl http://192.168.1.6/test1.html
<h1>RS1, ####172.16.1.8</h1>
[root@stephen ~]# curl http://192.168.1.6/test1.html
<h1>RS2,###172.16.1.9</h1>

[root@stephen ~]# for i in {1..10}; do curl http://192.168.1.6/test1.html; done
<h1>RS1, ####172.16.1.8</h1>
<h1>RS2,###172.16.1.9</h1>
<h1>RS1, ####172.16.1.8</h1>
<h1>RS2,###172.16.1.9</h1>
<h1>RS1, ####172.16.1.8</h1>
<h1>RS2,###172.16.1.9</h1>
<h1>RS1, ####172.16.1.8</h1>
<h1>RS2,###172.16.1.9</h1>
<h1>RS1, ####172.16.1.8</h1>
<h1>RS2,###172.16.1.9</h1>

 

LVS-DR模型:

Direct Routing,直接路由;

經過爲請求報文從新封裝一個MAC首部進行轉發,源MAC是DIP所在的接口的MAC,
目標MAC是某挑選出的RS的RIP所在接口的MAC地址;源IP/PORT,以及目標IP/PORT均保持不變;

Director和各RS都得配置使用VIP;
(1) 確保前端路由器將目標IP爲VIP的請求報文發往Director:
(a) 在前端網關作靜態綁定;
(b) 在RS上使用arptables;
(c) 在RS上修改內核參數以限制arp通告及應答級別;
arp_announce
arp_ignore
(2) RS的RIP能夠使用私網地址,也能夠是公網地址;RIP與DIP在同一IP網絡;RIP的網關不能指向DIP,以確保響應報文不會經由Director; 他們的網關相同能夠嗎?
(3) RS跟Director要在同一個物理網絡;
(4) 請求報文要經由Director,但響應不能經由Director,而是由RS直接發往Client;
(5) 不支持端口映射;

 

1)準備:

1. 關閉selinux, 清空iptables, 同步dr, rs1, rs2上的時間

2. 在rs1, rs2上分別安裝httpd 在dr上安裝ipvsadm

3.dr, rs都是橋接

dr調度器: 
                   DIP: 192.168.1.6 
                   VIP: 192.16.1.99  在ens33:0上
rs1服務器1 RIP1:192.168.1.4

                  VIP: 192.168.1.99   在lo:0上
rs2服務器2 RIP2: 192.168.1.5
                  VIP: 192.168.1.99   在lo:0上

思考: vip要和rip在同一網段中嗎? 

            當VIP所有設置爲VIP: 172.16.0.99,結果失敗,地址0改成1後就成功了。

2)配置:

在RS1上:

# vim /var/www/html/test1.html        添加內容<h1> RS1, 192.168.1.4 </h1>

[root@bogon ~]# vim setparam.sh
[root@bogon ~]# cat setparam.sh
#!/bin/bash
#
vip='192.168.1.99'
mask='255.255.255.255'
iface='lo:0'

case $1 in
start)
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce

ifconfig $iface $vip netmask $mask broadcast $vip up
route add -host $vip dev $iface
;;
stop)
ifconfig $iface down

echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 0 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 0 > /proc/sys/net/ipv4/conf/lo/arp_announce

;;
*)
echo "Usage $(basename $0) start|stop"
exit 1
;;
esac

[root@bogon ~]# bash -n setparam.sh
[root@bogon ~]# bash -x setparam.sh start
+ vip=192.168.1.99
+ mask=255.255.255.255
+ iface=lo:0
+ case $1 in
+ echo 1
+ echo 1
+ echo 2
+ echo 2
+ ifconfig lo:0 192.168.1.99 netmask 255.255.255.255 broadcast 172.16.0.99 up
+ route add -host 192.168.1.99 dev lo:0

# scp setparam.sh 192.168.1.5:/root/

# systemctl start httpd.service

# ss -tnl                           檢查80端口是否打開

 

在RS2上:

[root@bogon ~]# ls
anaconda-ks.cfg setparam.sh
[root@bogon ~]# bash -x setparam.sh start
+ vip=192.168.1.99
+ mask=255.255.255.255
+ iface=lo:0
+ case $1 in
+ echo 1
+ echo 1
+ echo 2
+ echo 2
+ ifconfig lo:0 192.168.1.99 netmask 255.255.255.255 broadcast 192.168.1.99 up
+ route add -host 192.168.1.99 dev lo:0
[root@bogon ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::8b7:c57a:ebbd:80b7 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:9e:a5:df txqueuelen 1000 (Ethernet)
RX packets 15795 bytes 17043985 (16.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8126 bytes 786863 (768.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 4 bytes 336 (336.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4 bytes 336 (336.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo:0: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 192.168.1.99 netmask 255.255.255.255
loop txqueuelen 1000 (Local Loopback)

# vim /var/www/html/test1.html        添加內容<h1> RS2, 192.168.1.5 </h1>

# systemctl start httpd.service

# ss -tnl                       檢查80端口是否打開

 

在DR上:

[root@bogon network-scripts]# curl http://192.168.1.4/test1.html
<h1> RS1, 192.168.1.4 </h1>
[root@bogon network-scripts]# curl http://192.168.1.5/test1.html
<h1> RS2, 192.168.1.5 </h1>

[root@bogon network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.6 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::fb51:8e3:4aa5:5358 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:37:ff:fd txqueuelen 1000 (Ethernet)
RX packets 2310 bytes 241192 (235.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 476 bytes 42028 (41.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

[root@bogon network-scripts]# ifconfig ens33:0 192.168.1.99 netmask 255.255.255.255 broadcast 192.168.1.99 up

[root@bogon network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.6 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::fb51:8e3:4aa5:5358 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:37:ff:fd txqueuelen 1000 (Ethernet)
RX packets 2513 bytes 259088 (253.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 602 bytes 56844 (55.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ens33:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.99 netmask 255.255.255.255 broadcast 172.16.0.99
ether 00:0c:29:37:ff:fd txqueuelen 1000 (Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

 

 

在客戶端上:

[root@stephen ~]# curl http://192.168.1.99/test1.html<h1> RS1, 192.168.1.4 </h1>[root@stephen ~]# curl http://192.168.1.99/test1.html<h1> RS2, 192.168.1.5 </h1>[root@stephen ~]# for i in {1..15}; do curl http://192.168.1.99/test1.html; done<h1> RS1, 192.168.1.4 </h1><h1> RS2, 192.168.1.5 </h1><h1> RS1, 192.168.1.4 </h1><h1> RS2, 192.168.1.5 </h1><h1> RS1, 192.168.1.4 </h1><h1> RS2, 192.168.1.5 </h1><h1> RS1, 192.168.1.4 </h1><h1> RS2, 192.168.1.5 </h1><h1> RS1, 192.168.1.4 </h1><h1> RS2, 192.168.1.5 </h1><h1> RS1, 192.168.1.4 </h1><h1> RS2, 192.168.1.5 </h1><h1> RS1, 192.168.1.4 </h1><h1> RS2, 192.168.1.5 </h1><h1> RS1, 192.168.1.4 </h1>

相關文章
相關標籤/搜索