標籤:roo pad ipad red ppp com alias device RoCE
一、說明
想要流量分流,在一個介面上設定多IP的方式,是可以實現的,在互連網上需要訪問的網域名稱,一般人並不知道什麼是IP,就是知道IP,可能他們理解的IP(知識財產權)跟你理解的IP(互連網協議)並不一樣。基於IP的分流,目的在於訪問這些IP時開啟的網頁是一致的。分流網頁有很多種,這隻是其中的一種而已。
二、多IP設定
1.複製網路設定檔
[[email protected] ~]# cd /etc/sysconfig/network-scripts/[[email protected] network-scripts]# lsifcfg-ens33 ifdown-isdn ifdown-tunnel ifup-isdn ifup-Teamifcfg-lo ifdown-post ifup ifup-plip ifup-TeamPortifdown ifdown-ppp ifup-aliases ifup-plusb ifup-tunnelifdown-bnep ifdown-routes ifup-bnep ifup-post ifup-wirelessifdown-eth ifdown-sit ifup-eth ifup-ppp init.ipv6-globalifdown-ippp ifdown-Team ifup-ippp ifup-routes network-functionsifdown-ipv6 ifdown-TeamPort ifup-ipv6 ifup-sit network-functions-ipv6[[email protected] network-scripts]# cp ifcfg-ens33 ifcfg-ens33:1
2.修改設定檔
[[email protected] network-scripts]# vim ifcfg-ens33:1TYPE="Ethernet"BOOTPROTO="dhcp"NAME="ens33:1"DEVICE="ens33:1"ONBOOT="yes"IPADDR=192.168.116.100PREFIX=24GATEWAY=192.168.116.255[[email protected] network-scripts]#
3.重啟網路服務
[[email protected] network-scripts]# systemctl restart network[[email protected] network-scripts]# ip a1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:47:c4:9f brd ff:ff:ff:ff:ff:ff inet 192.168.116.129/24 brd 192.168.116.255 scope global noprefixroute dynamic ens33 valid_lft 1798sec preferred_lft 1798sec inet 192.168.116.100/24 brd 192.168.116.255 scope global secondary noprefixroute ens33:1 valid_lft forever preferred_lft forever inet6 fe80::ab30:473d:fe9e:9d7e/64 scope link noprefixroute valid_lft forever preferred_lft forever[[email protected] network-scripts]#
4.本地測試網路連通性
[C:\~]$ ping 192.168.116.100正在 Ping 192.168.116.100 具有 32 位元組的資料:來自 192.168.116.100 的回複: 位元組=32 時間<1ms TTL=64來自 192.168.116.100 的回複: 位元組=32 時間<1ms TTL=64來自 192.168.116.100 的回複: 位元組=32 時間<1ms TTL=64來自 192.168.116.100 的回複: 位元組=32 時間<1ms TTL=64192.168.116.100 的 Ping 統計資訊: 資料包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失),往返行程的估計時間(以毫秒為單位): 最短 = 0ms,最長 = 0ms,平均 = 0ms[C:\~]$
三、網頁分流
1.設定網頁
[[email protected] nginx]# mkdir /server/web/test1[[email protected] nginx]# mkdir /server/web/test2[[email protected] nginx]# mv /server/web/index.html test1/ test2/ [[email protected] nginx]# cp /server/web/index.html /server/web/test1/[[email protected] nginx]# cp /server/web/index.html /server/web/test2/[[email protected] nginx]# cat /server/web/index.html <h1 align=center>vhost</h1>[[email protected] nginx]# vim /server/web/test2/index.html [[email protected] nginx]# cat /server/web/test2/index.html <h1 align=center>test2 vhost</h1>[[email protected] nginx]#
2.建立NGINX設定檔
[[email protected] nginx]# lsconf html logs sbin[[email protected] nginx]# cd conf/[[email protected] conf]# lsfastcgi.conf koi-utf nginx.conf uwsgi_paramsfastcgi.conf.default koi-win nginx.conf.default uwsgi_params.defaultfastcgi_params mime.types scgi_params win-utffastcgi_params.default mime.types.default scgi_params.default[[email protected] conf]# mkdir vhost[[email protected] conf]# vim nginx.confinclude vhost/*.conf; #在最後括弧上添加[[email protected] conf]# lsfastcgi.conf koi-utf nginx.conf uwsgi_paramsfastcgi.conf.default koi-win nginx.conf.default uwsgi_params.defaultfastcgi_params mime.types scgi_params vhostfastcgi_params.default mime.types.default scgi_params.default win-utf[[email protected] conf]# cd vhost/[[email protected] vhost]# lstest1.conf test2.conf[[email protected] vhost]# cat test1.conf server { listen 80; server_name 192.168.116.129 ; index index.html index.htm index.php; root /server/web/test1 ;}[[email protected] vhost]# cat test2.conf server { listen 80; server_name 192.168.116.100 ; index index.html index.htm index.php; root /server/web/test2 ;}[[email protected] vhost]#
3.重啟NGINX服務
[[email protected] vhost]# /usr/local/nginx/sbin/nginx -s reload如果是第一次啟動NGINX服務,執行這條命令:[[email protected] vhost]# /usr/local/nginx/sbin/nginx
4.訪問網頁
5.設定訪問同一個網頁
[[email protected] vhost]# vim /server/web/index.html [[email protected] vhost]# cat /server/web/index.html <h1 align=center>test1 and test2 share web page</h1>[[email protected] vhost]# vim test2.conf [[email protected] vhost]# vim test1.conf [[email protected] vhost]# /usr/local/nginx/sbin/nginx -s reload[[email protected] vhost]# cat test1.conf server { listen 80; server_name 192.168.116.129 ; index index.html index.htm index.php; root /server/web ;}[[email protected] vhost]# cat test2.conf server { listen 80; server_name 192.168.116.100 ; index index.html index.htm index.php; root /server/web ;}[[email protected] vhost]#
6.訪問網頁
至此基於IP實現網頁分流已完成
基礎營運:基於IP實現網頁分流