您的位置:首页 > 理论基础 > 计算机网络

创建论坛 squid部署代理 高级网络控制

2018-02-03 13:48 447 查看
解压zip uzip

创建论坛

下载好 论坛模版 查看安装说明

cp -r upload   /var/www/html  ##按照说明将下载好cp到默认发布目录下的upload
chmod  777 /var/www/html/upload/*  -R  ##给权限
[root@apache upload]# ls
admin.php  connect.php      forum.php  member.php  search.php  uc_server
api        cp.php           group.php  misc.php    source      userapp.php
api.php    crossdomain.xml  home.php   plugin.php  static
archiver   data             index.php  portal.php  template
config     favicon.ico      install    robots.txt  uc_client
systemctl  start  mariadb  ##开启数据库
systemctl  enable  mariadb


在浏览器中访问/upload 并安装







使用squid部署代理

用虚拟机 (server  IP:102):
搭建squid代理的server:
vim /etc/sysconfig/network-script/ifcfg-eth0  ##修改成能上网的服务器
systemctl  restart   network             ##重启
vim /etc/resolv.conf     ##修改DNS域名解析
nameserver  114.114.114.114


正向代理

yum install  squid   ##安装squid
vim /etc/squid/squid.conf  ##编写squid的配置文件

56 http_access allow  all  ##允许所有
62 cache_dir ufs /var/spool/squid 100 16 256  ##缓存的大小 100M  16个目录 256文件

systemctl  restart  squid


测试:

真机没网的前题下

用真机的浏览器 :修改浏览器配置(preference-Advanced-settings…-选手动manual添加代理的IP和端口-选择 Use this proxy server for all protocols)



登陆代理的IP是否能上网

若能上网 是否能ping通网络 (若能上网且ping不通网络 则实验成功)

反向代理

新打开一个纯净的虚拟机 (Desktop IP:202 不能装apache 这只是个调度器 若装apache 会冲突)

yum  install    squid  - y
vim /etc/squid/squid.conf  ##编写squid 的配置文件
56 http_access allow all   ##允许
57
58 # Squid normally listens to port 3128
59 http_port 80 vhost  vport     ##客户端访问的默认端口就是80   vhost       vport
60 cache_peer 172.25.254.102  parent  80 0 no-query   ##缓存来自172.25.254.102 , 80 端口 0 没有替换的服务器  no-query不通知
systemctl  stop  firewalld
systemctl  mask  firewalld
systemctl  restart  squid


测试:

用真机浏览器 修改配置(preference-Advanced-settings…-NO proxy) ##关闭以前server的代理

登陆172.25.254.202 是否为102的主页内容

Squid平衡轮询

打开调度器 (Desktop虚拟机 )

vim /etc/squid/squid.conf  ##编辑squid配置文件“:

http_port 80 vhost  vport
cache_peer 172.25.254.102  parent  80 0 no-query   originserver round-robin  name=webserver1
cache_peer 172.25.254.110  parent  80 0 no-query   originserver round-robin  name=webserver2
cache_peer_domain  webserver1  webserver2  www.westos.com ##这个网站有2个主机提供服务
systemctl  restart  squid    ##


测试:

给主机本地域名解析 www.westos.com 172.25.254.202 (调度器的IP)

登陆到www.westos.com 查看 刷新网页 102 和 110 的主页会循环出现

高级网络控制

链路聚合

创建一个网卡振裂

手动添加两块网卡

bond ##可以装2块网卡

nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.102/24 ##网卡类型

nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0

nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond1

测试: watch -n 1 cat “/proc/”

ifconfig eth0 down ##关掉eth0 eth1会up ,继续工作

team 最多可以装8块网卡

nmcli connection add type team con-name team0 ifname team0 config ‘{“runner”:{“name”:”activebackup”}}’ip4 172.25.254.102/24

nmcli connection add con-name eth0 ifname eth0 type team-slave master team0

nmcli connection add con-name eth1 ifname eth1 type team-slave master team0

测试: watch -n 1 teamdctl team0 state

ifconfig eth0 down ##关掉eth0 eth1会up ,继续工作

桥接

主机:(删除无关网络 )

cd /etc/sysconfig/network-scripts/
mv ifcfg-br0 vim ifcfg-enp0s25 /mnt  ##将以前的桥接配置文件移到 /mnt
重启系统


cd /etc/sysconfig/network-script/  ##

vim ifcfg-enp0s25    ##编辑配置文件

DEVICE=enp0s25
ONBOOT=yes
BOOTPROTO=none
BRIDGE=br0


vim ifcfg-br0         ##编辑桥接配置文件

DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
TYPE=Bridge
IPADDR=172.25.254.2   ##主机IP
POEFIX=24


虚拟机 :
brctl  addbr  br0
brctl  show
[root@apache ~]# brctl  show
bridge name bridge id       STP enabled interfaces
br0     8000.5254009f1486   no
ifconfig  br0  172.25.254.102  netmask 255.255.255.0
ping 172.25.254.2   ##ping不通
brctl  addif  br0   eth0  ## 将桥接br0 加在网卡eth0 上
ping  172.25.254.2  ##通
brctl  show
bridge name bridge id       STP enabled interfaces
br0     8000.5254009f1486   no      eth0


删除桥接

ifconfig br0 down

brctl delif br0 eth0 ##删除桥接

brctl show

brctl delbr br0 ##删除br0

brctl show
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: