惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
T
Tenable Blog
D
DataBreaches.Net
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
腾讯CDC
V
Visual Studio Blog
B
Blog
雷峰网
雷峰网
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
I
InfoQ
M
MIT News - Artificial intelligence
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
The Cloudflare Blog
L
LangChain Blog
MongoDB | Blog
MongoDB | Blog
Vercel News
Vercel News
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
博客园 - 司徒正美
T
The Exploit Database - CXSecurity.com
Google DeepMind News
Google DeepMind News
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Attack and Defense Labs
Attack and Defense Labs
Martin Fowler
Martin Fowler
SecWiki News
SecWiki News
T
Threat Research - Cisco Blogs
J
Java Code Geeks
Cyberwarzone
Cyberwarzone
Forbes - Security
Forbes - Security
Spread Privacy
Spread Privacy
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
O
OpenAI News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Schneier on Security
Schneier on Security
S
Security @ Cisco Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
The Hacker News
The Hacker News
H
Help Net Security
Y
Y Combinator Blog
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tor Project blog
量子位
U
Unit 42
S
SegmentFault 最新的问题
V
V2EX
D
Docker

博客园 - 老管

freebsd.org改版 安装lilina续 - 更改首页显示天数 不重启更新rc.conf socks5-v1.0r11.tar.gz安装笔记 在线rss阅读聚合器lilina-0.7安装笔记 设置CMOS使服务器断电来电后自动开机 使win2003自动登陆 freebsd下安装GIMP FreeBSD5.4Release中文工作站安装笔记 (Freebsd5.4R+Gnome2.10.0) 《freebsd下gdm的安装》续 freebsd下gdm的安装 安装freebsd后win2000不能进入 vsmon.exe进程对CPU资源的占用问题 找出windows2000的boot.ini文件 不重启机器的情况下重启rc.conf 突然断电导致freebsd服务器文件系统检测错误-fsck 代理服务器又出现mbuf clusters exhausted 故障 .. 一次网络故障的排除-都是3COM光纤模块惹的祸 关于squid禁止某些站点的访问的控制 (acl语句)
FreeBSD代理服务器(proxy)的“改造”
老管 · 2005-07-09 · via 博客园 - 老管

为了能提供更丰富的网络服务功能,准备改造代理服务器。

原功能:提供squid的http请求服务,提供socks5的网络服务

改造后的功能:提供squid的http请求服务(不用改变客户端网络设置),利用freebsdipfilter模块提供网络包过滤和网络地址转换(根据需要开通某些客户端,但需重新设置客户端)


具体操作:

说明:vr0:外网网卡接口218.90.x.x;vr1:内网网卡接口192.168.1.254

1、编辑/etc/rc.local将启动socks5服务的一行去掉

2、重新编译内核

# cd /sys/i386/conf
# cp funpower funpower2 //funpower为现内核名
# ee funpower2 //用ee打开funpower2,新添加如下三行:

options IPFILTER
options IPFILTER_LOG
options IPFILTER_DEFAULT_BLOCK

接下来重新编译内核:

# /usr/sbin/config funpower2
# cd ../../compile/funpower2
# make depend
# make
# make install

如果没有error之类的错误句,说明你的内核已编译成功。
如果你是直接在机器前操作的,可以重启机器了,但如果你是利用telnet或者ssh连接到服务器进行以上操作的,请不要急着现在重启,

因为刚才在内核中加入的ipfilter默认是阻止一切连接,继续往下操作


3、编辑/etc/rc.conf

# ee /etc/rc.conf //用ee打开/etc/rc.conf,回入如下语句:

ipfilter_enable="YES"
ipfilter_rules="/etc/ipf.conf"
ipnat_enable="YES"
ipnat_rules="/etc/ipnat.conf"
gateway_enable="YES"

4、在/etc下创建ipf.conf和ipnat.conf

# ee ipnat.conf //利用ee创建ipnat.conf

rdr vr1 0.0.0.0/0 port 80 -> 192.168.1.254 port 3128
map vr0 192.168.1.0/24 -> 0/32 proxy port ftp ftp/tcp
map vr0 192.168.1.0/24 -> 0/32 portmap tcp/udp 10000:30000
map vr0 192.168.1.0/24 -> 0/32 portmap

# ee ipf.conf //利用ee创建ipf.conf,这个文件视你的网络情况而定

block in log quick all with short
block in log quick all with ipopts
block in log quick all with frag
block in log quick all with opt lssr
block in log quick all with opt ssrr

pass out on vr1 all
pass in on vr1 all
pass out quick on lo0 all
pass in quick on lo0 all

block out on vr0 all
pass out log on vr0 proto tcp/udp from 218.90.x.x to any keep state

pass out log on vr0 proto tcp/udp from 192.168.1.1 to any keep state
pass out log on vr0 proto tcp/udp from 192.168.1.2 to any keep state
pass out log on vr0 proto tcp/udp from 192.168.1.3 to any keep state

pass out log on vr0 proto icmp all keep state
pass out log on vr0 proto tcp/udp from any to any keep state
pass in quick on vr0 proto tcp from any to any port = ftp-data keep state
pass in quick on vr0 proto tcp from any port = ftp-data to any port>1023 keep state

注:ipf.conf和ipnat.conf推荐一篇文章.


5、重启机器,设置客户端

到这儿重启后对telnet和ssh就没影响了,因为在ipf.conf已经加入了内网网卡的通行规则。
客户端设置,对于原来的只需http上网的用户客户端无需修改网络设置,需要ipfilter的首先需在ipf.conf中加入规则表,然后网络设置

也要填上网关:192.168.1.254和DNS地址,才能使用。

以上是简要的改造过程,错误之处肯定有,欢迎转载,转载请保留原作者信息,作者:管建丰;交流: funpower(at)gmail.com