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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 老管

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