iptables 无法上网_centos6.8安装squid代理服务器server及client配置代理上网

问题:局域网内目前有2台服务器,一台可以上网,另一台无法上网,目前解决此问题通过代理解决;

1、系统环境

操作系统:CentOS release 6.8 (Final)

Squid版本:squid-3.1.10-20.el6_5.3.x86_64

SELINUX=disabled #这个我没配置

HTTP Service: stoped #这个我没配置

2、安装Squid服务,squid我安装在192.168.0.15这个机器,还有一台不能上网的内网192.168.0.11;

检查squid软件是否安装

# rpm -qa|grep squid

26bbd080c1149a34abd6d6ea47fac06d.png

如果未安装,则使用yum 方式安装

# yum -y install squid

cf27a469eed1150ed7440dc2f73b2ab4.png

设置开机自启动

//自动运行squid服务

chkconfig squid on

//建立缓存目录

squid -z

9a1f157d617c787b65a016f64b7efb99.png

3、修改squid的配置文件

配置文件位置在:/etc/squid/squid.conf

acl manager proto cache_object

acl localhost src 127.0.0.1/32 ::1

acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

acl localnet src 192.168.0.11/18

acl SSL_ports port 443

# http

acl Safe_ports port 80

# ftp

acl Safe_ports port 21

# https

acl Safe_ports port 443

# gopher

acl Safe_ports port 70

# wais

acl Safe_ports port 210

# unregistered ports

acl Safe_ports port 1025-65535

# http-mgmt

acl Safe_ports port 280

# gss-http

acl Safe_ports port 488

# filemaker

acl Safe_ports port 591

# multiling http

acl Safe_ports port 777

acl CONNECT method CONNECT

http_access allow manager localhost

http_access deny manager

http_access deny !Safe_ports

http_access deny CONNECT !SSL_ports

http_access allow localnet

http_access allow localhost

http_access deny all

# listens port 3128

http_port 3128

cache_dir ufs /var/spool/squid 100 16 256

coredump_dir /var/spool/squid

refresh_pattern ^ftp: 1440 20% 10080

refresh_pattern ^gopher: 1440 0% 1440

refresh_pattern -i (/cgi-bin/|?) 0 0% 0

refresh_pattern . 0 20% 4320

strip_query_terms off

visible_hostname 192.168.0.15

cache_mgr zoujiansong@sxcx-tech.com

cache_store_log none

cache_access_log none

cache_mem 512 MB

cache_swap_low 90

cache_swap_high 95

#下载文件最大128M

maximum_object_size 128 MB

#下载文件最大128M

maximum_object_size_in_memory 128 MB

dns_nameservers 8.8.8.8 8.8.4.4

client_lifetime 1 minutes

half_closed_clients off

fqdncache_size 65535

ipcache_size 65535

ipcache_low 90

ipcache_high 95

4、配置防火墙

vi /etc/sysconfig/iptables

#开放端口3128对所有ip

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3128 -j ACCEPT

或者

#开放端口3128对指定ip

-A INPUT -s 192.168.0.11 -m state --state NEW -m tcp -p tcp --dport 3128 -j ACCEPT

重启 service iptables restart

启动:service squid start

重启:service squid restart

停止:service squid stop

bc1e744fcbd6c50ec9c0f770b3c4c334.png

5、配置内网其他机器代理上网,如内网192.168.0.11机器上配置yum可以使用代理

vi /etc/yum.conf

增加如下部分

proxy=http://192.168.0.15:3128

proxy=https://192.168.0.15:3128

proxy=ftp://192.168.0.15:3128

如下图:

5a058718739c793f12ac48543d9428fe.png

yum命令在11机器就可以下载了

6、wget代理配置

打开vi /etc/wgetrc 文件

https_proxy = http://192.168.0.15:80/

http_proxy = http://192.168.0.15:80/

ftp_proxy = http://192.168.0.15:80/

use_proxy = on

e2c410bfadca30532446b96fae99a0d3.png

注意不要忘记写ftp_proxy, 否则在下载ftp内容时会无法解析

cc23bfb938e095588e28d6b8752ea841.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值