linux下配置网络代理

背景:有几台华为云节点,只有一个节点可以访问互联网,其他节点无法访问互联网,这给安装软件带来不便(因为我们常常使用yum安装软件,但是这个需要联网才行)

1 配置代理服务器

安装代理软件squid

yum install squid

配置

vi /etc/squid/squid.conf
复制代码
# 主要是标红的那些配置,其他配置保持默认即可
# Recommended minimum configuration:
#

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src xxx.xxx.xxx.xxx/xx        # RFC1918 possible internal network 这里是允许访问的客户端网络地址
# acl localnet src 172.16.0.0/12        # RFC1918 possible internal network
# acl localnet src 192.168.0.0/16       # RFC1918 possible internal network
# acl localnet src fc00::/7       # RFC 4193 local private network range
# acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80          # http
# acl Safe_ports port 21                # ftp
acl Safe_ports port 443         # https
# acl Safe_ports port 210               # wais
# acl Safe_ports port 1025-65535        # unregistered ports
# acl Safe_ports port 280               # http-mgmt
# acl Safe_ports port 488               # gss-http
#acl Safe_ports port 591                # filemaker
#acl Safe_ports port 777                # multiling http
acl CONNECT method CONNECT
复制代码

启动服务

systemctl start squid

2 配置客户端

 vi ~/.bashrc 

添加如下配置

export http_proxy=http://10.xxx.xxx.76:3128
export https_proxy=https://10.xxx.xxx.76:3128

生效

 source ~/.bashrc 

3 试一试

我们使用yum安装软件试试,如下图,可以上网了

 

posted @   zhenjingcool  阅读(99)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
历史上的今天:
2022-01-06 tcp/ip-CLOSE-WAIT、TIME-WAIT 、LISTENING、SYN_SENT、ESTABLISHED等状态说明
点击右上角即可分享
微信分享提示