首页 > 系统相关 >Linux互联网主机代理内网主机访问互联网

Linux互联网主机代理内网主机访问互联网

时间:2025-01-16 13:55:31浏览次数:1  
标签:localnet http 主机 port acl access 互联网 Linux ports

互联网主机

1、安装squid
squid代理内网主机访问互联网

yum -y install squid
cat /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 10.0.0.0/8     # RFC1918 possible internal network
acl localnet src 192.66.1.0/24  # RFC1918 possible internal network      内网地址
acl localnet src 192.66.0.0/24  # RFC1918 possible internal network
acl localnet src 192.66.255.120 # RFC1918 possible internal network
acl localnet src 192.66.255.130 # 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

#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
#http_access deny all                                             #注释
http_access allow all                                             #添加

# Squid normally listens to port 3128
http_port 3128

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320

2、重启服务

systemctl restart squid
netstat -an | grep 3128

内网主机

1、配置环境变量

cat ~/.profile
# ~/.profile: executed by Bourne-compatible login shells.

if [ "$BASH" ]; then
  if [ -f ~/.bashrc ]; then
    . ~/.bashrc
  fi
fi

mesg n 2> /dev/null || true


alias proxy='export http_proxy=http://192.67.0.67:3128;export https_proxy=http://192.67.0.67:3128'
alias unproxy='unset http_proxy https_proxy'
# IP为要连接的代理服务器B,端口是要代理的端口,如下的意思该服务器要通过172.20.100.201服务器的端口8898的代理来访问外网

注意:
centos修改 vi ~/.bash_profile
ubuntu修改 vi ~/.profile

2、配置代理

source ~/.profile
proxy
echo $http_proxy

3、配置apt源

cp /etc/apt/sources.list /etc/apt/sources.list-bak
cat > /etc/apt/sources.list << EOF
deb http://192.168.0.201/ubuntu/ focal main restricted universe multiverse
deb-src http://192.168.0.201/ubuntu/ focal main restricted universe multiverse

deb http://192.168.0.201/ubuntu/ focal-security main restricted universe multiverse
deb-src http://192.168.0.201/ubuntu/ focal-security main restricted universe multiverse

deb http://192.168.0.201/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://192.168.0.201/ubuntu/ focal-updates main restricted universe multiverse

deb http://192.168.0.201/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://192.168.0.201/ubuntu/ focal-backports main restricted universe multiverse
EOF

apt update

参考

使用squid 解决内网服务器通过设置代理访问外网
Ubuntu 20.04 与22.04 内网apt源搭建

标签:localnet,http,主机,port,acl,access,互联网,Linux,ports
From: https://www.cnblogs.com/OpenSourceSite/p/18674530

相关文章

  • Ubuntu升级Linux内核教程
    本文作者CVE-柠檬i:https://www.cnblogs.com/CVE-Lemon本文使用的方法是dpkg安装,目前版本为5.4.0-204,要升级成5.8.5版本下载下载网站:https://kernel.ubuntu.com/mainline/在该网站下载deb包,选择自己想要升级的版本,这里是5.8.5https://kernel.ubuntu.com/mainline/v5.8.5/am......
  • Linux Shell 脚本编程基础知识篇—sed文本处理工具
    ℹ️大家好,我是练小杰,今天是周三了,距离星期五还有两天......
  • C语言——linux 【互斥锁、死锁、信号量、条件变量】内附代码及练习
    1、思维导图2、互斥锁1.互斥锁实现互斥的代码3.防死锁默认防死锁trylock(不推荐,容易破环互斥的同步性)常用防死锁的方式有——递归锁、错误检查锁函数原型:intpthread_mutexattr_settype(pthread_mutexattr_t*attr,intkind);功能描述:将互斥锁属性attr,设置成kind类......
  • linux、git、adb常用命令
    linux:ls:查看所有当前目录下文件和目录名称pwd:查看当前路径mkdir:增加文件rmdir:删除文件mv:移动或重命名cp:复制gzip:添加解压gz格式tar:添加或解压tar格式zip:添加或解压zip格式adb:adbdevices:查看设备adbinstall:安装应用adbunstall:删除应用adblogcat:查看设备日志a......
  • Linux运维学习记录13
    1.在两台服务器上安装kvm虚拟化,把其中一台的虚拟机迁移到另一台。一台服务器apt-getupdateapt-yinstallcpu-checkeraptinstallqemu-kvmvirt-managerlibvirt-daemon-systemapt-yinstallbridge-utilsaptupdate&&apt-yinstallcockpitcockpit-machines创建......
  • 如何调整虚拟主机中网站后台的超时设置
    问题描述: 用户在登录网站后台后,短时间内会自动跳转到登录页面,导致无法正常操作。用户询问如何设置或调整网站后台的超时时间。回答: 为了确保网站后台的稳定性和用户体验,调整超时时间是一个常见的需求。以下是详细的步骤和建议:检查程序池设置:网站后台的超时问题可能与IIS中......
  • Linux创建虚拟WLAN接口并测试
    Linux创建虚拟WLAN接口并测试|DD'NotesLinux创建虚拟WLAN接口并测试创建虚拟WLAN接口主要通过mac80211_hwsim内核模块实现,该模块可以模拟多个无线网卡设备,并支持创建虚拟的WLAN接口。mac80211_hwsim简介mac80211_hwsimisaLinuxkernelmodulethatcanbeusedtosimu......
  • Linux权限详解(chmod、600、644、700、711、755、777、4755、6755、7755)
    Linux权限详解Linux系统上对文件的权限有着严格的控制,用于如果相对某个文件执行某种操作,必须具有对应的权限方可执行成功。这也是Linux有别于Windows的机制,也是基于这个权限机制,Linux可以有效防止病毒自我运行,因为运行的条件是必须要有运行的权限,而这个权限在Linux是用户所赋予的......
  • Linux C 使用ZBar库解析二维码和条形码
    1.编译zbar库下载zbar库源码,这里需要注意下,如果识别的二维码中有中文的话,会出现乱码,一般二维码里中文为UTF-8编码,zbar会默认给你把UTF-8转换为ISO8859-1。有两种解决办法,一是自己再转换一下编码格式;二是修改下zbar源码,很简单,只需要修改源码目录下的zbar/qrcode/qrdectxt.c......
  • 【Linux运维】如何在Linux中列出USB设备
    Linux操作系统提供了许多命令来列出系统中连接的USB设备。这些命令非常有用,无论是查看已连接设备的信息还是进行系统调试。在本文中,我们将介绍一些常用的命令以及它们的使用方法,帮助你了解如何在Linux中列出USB设备。1、lsusb命令lsusb命令是列出USB设备信息的常用命令。它会显......