【防火墙透明代理配置心得----原创】
发表于:2007-05-26来源:作者:点击数:
标签:
-------------------------------------------------------------------------------- 声明:本文章为wangbin原创,互联网上论坛大家可以任意站贴 但是请您注明文章来源http://www.enhand.net[wangbin] 印刷报刊,谢绝使用! 原文地址:http://www.enhand.ne
--------------------------------------------------------------------------------
声明:本文章为wangbin原创,互联网上
论坛大家可以任意站贴
但是请您注明文章来源 http://www.enhand.net [wangbin]
印刷报刊,谢绝使用!
原文地址: http://www.enhand.net/bbs/viewtopic.php?p=679#679
本人是一个新手,2002年刚刚学习FreeBSD,在CU上经常受到大家的嘲笑,这次配置
也是饱经曲折,所以我希望的做法能够为后来的朋友有所启示。
单位100M光纤接入互联网,文章中网卡为ed0[202.182.96.2],内网ed2的地址为200.200.1.0/24,其中200.200.1.33是一台web
服务器。
要完成的任务是,使所有的互联网微机可以访问200.200.1.33,所有的内网主机可以访问互联网。
规则暂时不考虑,网上相关的文章也很多。
DL# cat ipnat.rules
代码:
map ed0 200.200.1.0/24 -> 202.182.96.2/32 portmap tcp/udp 1000:6000
map ed0 200.200.1.0/24 -> 202.182.96.2/32 proxy port ftp ftp/tcp
map ed0 200.200.1.0/24 -> 202.182.96.2/32
rdr ed0 0.0.0.0/0 port 80 -> 200.200.1.33 port 80 tcp
DL# cat ipf.rules
代码:
pass in quick on lo0 all
pass out quick on lo0 all
pass in from any to any
pass out from any to any
/etc/rc.conf
代码:
DL# cat rc.conf
defaultrouter="218.22.205.1"
hostname="DL.net"
network_interfaces="ed0 ed2 lo0"
ifconfig_ed0="inet 202.182.96.2 netmask 255.255.255.248"
ifconfig_ed2="inet 200.200.1.180 netmask 255.255.255.0"
sendmail_enable="NONE"
inetd_enable="NO"
kern_securelevel_enable="NO"
linux_enable="YES"
nfs_reserved_port_only="NO"
sshd_enable="YES"
usbd_enable="NO"
gateway_enable="YES"
#######################IPFILTER###########
ipfilter_enable="YES"
ipfilter_program="/sbin/ipf"
ipfilter_rules="/etc/ipf.rules"
ipfilter_flags=""
ipnat_enable="YES"
ipnat_program="/sbin/ipnat"
ipnat_rules="/etc/ipnat.rules"
ipnat_flags=""
######################IPFW#################
#firewall_enable="YES"
#firewall_script="/etc/rc.firewall"
#firewall_type="open"
#firewall_quiet="NO"
#firewall_logging_enable="YES"
#natd_enable="YES"
#natd_interface="ed0"
#natd_flags="-config /etc/natd.conf"
内核文件,注意 options BRIDGE
代码:
DL# cd /usr/src/sys/i386/conf/
DL# cat DL
machine i386
cpu I686_CPU
ident DL
maxusers 0
options MATH_EMULATE #Support for x87 emulation
options INET #InterNETworking
options FFS #Berkeley Fast Filesystem
options FFS_ROOT #FFS usable as root device [keep this!]
options SOFTUPDATES #Enable FFS soft updates support
options UFS_DIRHASH #Improve performance on big directories
options CD9660_ROOT #CD-ROM usable as root, CD9660 required
options PROCFS #Process filesystem
options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!]
options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI
options UCONSOLE #Allow users to grab the console
options USERCONFIG #boot -c editor
options VISUAL_USERCONFIG #visual boot -c editor
options KTRACE #ktrace(1) support
options SYSVSHM #SYSV-style shared memory
options SYSVMSG #SYSV-style message queues
options SYSVSEM #SYSV-style semaphores
options P1003_1B #Posix P1003_1B real-time extensions
options _KPOSIX_PRIORITY_SCHEDULING
options ICMP_BANDLIM #Rate limit bad replies
options KBD_INSTALL_CDEV # install a CDEV entry in /dev
options AHC_REG_PRETTY_PRINT # Print register bitfields in de
bug
# output. Adds ~128k to driver.
options AHD_REG_PRETTY_PRINT # Print register bitfields in debug
# output. Adds ~215k to driver.
##################this is ok for ipfw#######
#options IPFIREWALL
#options IPFIREWALL_VERBOSE
#options IPFIREWALL_VERBOSE_LI
MIT=90
#options IPFIREWALL_DEFAULT_TO_A
CCEPT
#options IPDIVERT
####################for bridge############
options BRIDGE
options IPFILTER
options ACCEPT_FILTER_DATA
options ACCEPT_FILTER_HTTP
options ICMP_BANDLIM
device isa
device eisa
device pci
options AUTO_EOI_1
options RANDOM_IP_ID
options TCP_DROP_SYNFIN
options PANIC_REBOOT_WAIT_TIME=0
device ata0 at isa? port IO_WD1 irq 14
device ata1 at isa? port IO_WD2 irq 15
device ata
device atadisk # ATA disk drives
device atapicd # ATAPI CDROM drives
options ATA_STATIC_ID #Static device numbering
# SCSI Controllers
device ahb # EISA AHA1742 family
device ahc # AHA2940 and onboard AIC7xxx devices
device ahd # AHA39320/29320 and onboard AIC79xx devices
device amd # AMD 53C974 (Tekram DC-390(T))
device isp # Qlogic family
device mpt # LSI-Logic MPT/Fusion
device ncr # NCR/Symb
ios Logic
device sym # NCR/Symbios Logic (newer chipsets)
options SYM_SETUP_LP_PROBE_MAP=0x40
# Allow ncr to attach legacy NCR devices when
# both sym and ncr are configured
device adv0 at isa?
device adw
device bt0 at isa?
device aha0 at isa?
device aic0 at isa?
device ncv # NCR 53C500
device nsp # Workbit Ninja SCSI-3
device stg # TMC 18C30/18C50
# SCSI peripherals
device scbus # SCSI bus (required)
device da # Direct A
clearcase/" target="_blank" >ccess (disks)
device cd # CD
device pass # Passthrough device (direct SCSI access)
# atkbdc0 controls both the keyboard and the PS/2 mouse
device atkbdc0 at isa? port IO_KBD
device atkbd0 at atkbdc? irq 1 flags 0x1
device psm0 at atkbdc? irq 12
device vga0 at isa?
# splash screen/screen saver
pseudo-device splash
# syscons is the default console driver, resembling an SCO console
device sc0 at isa? flags 0x100
device agp # support several AGP chipsets
device sc
options MAXCONS=2 ##
options SC_DISABLE_REBOOT
options SC_NO_CUTPASTE #
options SC_NO_FONT_LOADING #
options SC_NO_SYSMOUSE
device npx0 at nexus? port IO_NPX irq 13
# Parallel port
device ppc0 at isa? irq 7
device ppbus # Parallel port bus (required)
device plip # TCP/IP over parallel
device ppi # Parallel port interface device
device miibus # MII bus support
device rl # RealTek 8129/8139
#device ed0 at isa? port 0x300 net irq 3 iomem 0xd8000 vector edintr #
device ed0 at isa? disable port 0x300 irq 3 iomem 0xd8000
device pty
# Pseudo devices - the number indicates how many units to allocate.
pseudo-device loop # Network loopback
pseudo-device ether # Ethernet support
pseudo-device bpf #Berkeley packet filter
wangbin 回复于:2003-11-02 11:33:02
|
IPFIREWALL方式和IPFILTER方式都可以选择,本文暂时使用IPFILTER方式,如果IPFIREWALL方式试验成功了,会和大家分享!:)
|
frankzh 回复于:2003-11-02 11:43:52
|
第一个 掌声 鼓励 。。。。。!
我也刚接触 freebsd 在做 ipfw和 natd时 也是出现问题,网上一些大虾 文章不错 但是需要注意的细节 却不肯 写清楚 一点, 尤其是 natd重复执行这一个方面 也就是 错误 natdnatd: Unable to bind divert socket.: Address already in use 的时候
|
wangbin 回复于:2003-11-02 11:51:11
|
不过我还是一点不理解
[color=darkred:79e82a95d3]options BRIDGE [/color:79e82a95d3]
是一种网桥的方式,我发现在FreeBSD4.9中,我把下面的代码,加入sysctl.conf和不加的效果一模一样,真有些不能理解。
[code:1:79e82a95d3]sysctl net.link.ether.bridge_cfg=ed0:0,ed21:0
sysctl net.link.ether.bridge_ipf=1
sysctl net.link.ether.bridge=1 [/code:1:79e82a95d3]
|
linyin 回复于:2003-11-02 17:18:53
|
放心,在这没人会笑你
大伙都是鸟鸟过来的
|
wangbin 回复于:2003-11-03 12:28:41
|
可能只有兄弟你!
|
zsflower 回复于:2003-11-03 13:44:05
|
[quote:027972d019="wangbin"]S!]
options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI
options UCONSOLE #Allow users to grab the console
options USERCONFIG #b..........[/quote:027972d019]
老大,这样改很大工程呀,你试通了真的能跳转没有?
|
wangbin 回复于:2003-11-03 14:18:35
|
当然了,看看这个 http://xc.enhand.net 我同事的机器,但是有时候不开机,只是测试了!
|
zsflower 回复于:2003-11-03 14:50:07
|
[quote:de59265e35="wangbin"]当然了,看看这个 http://xc.enhand.net 我同事的机器,但是有时候不开机,只是测试了![/quote:de59265e35]利害,我今晚换系统。哈哈,谢谢你的体验了。
|
zsflower 回复于:2003-11-03 14:51:38
|
[quote:b62601c85c="wangbin"]当然了,看看这个 http://xc.enhand.net 我同事的机器,但是有时候不开机,只是测试了![/quote:b62601c85c]有没有QQ呀你,加我好吗?平时一起研究一下 我的Q113118569
|
netter_ruan 回复于:2003-11-04 21:11:11
|
好象没有实现透明代理的概念,只是做了nat+rdr呀.
|
wangbin 回复于:2003-11-04 22:00:51
|
[quote:b0614e379d="netter_ruan"]好象没有实现透明代理的概念,只是做了nat+rdr呀.[/quote:b0614e379d]
确切的讲 ipnatd+网桥+Ipfilter
|
statue 回复于:2003-11-04 22:42:13
|
完全錯誤的標題....
如果只是要達到你上面的要求, 幾行就解決了.....
|
iceblood 回复于:2003-11-04 23:16:23
|
[quote:b467ef50c3="frankzh"]第一个 掌声 鼓励 。。。。。!
我也刚接触 freebsd 在做 ipfw和 natd时 也是出现问题,网上一些大虾 文章不错 但是需要注意的细节 却不肯 写清楚 一点, 尤其是 natd重复执行这一个方面 也就是 错误 natdnatd: U..........[/quote:b467ef50c3]
不是不肯写清楚,而是很简单。
在你编辑完/etc/natd.conf以后。就可以进行以下操作了:
natd是一个进程,要重新执行的话就先killall natd进程。
执行完killall以后NATD并不会立刻结束,你可能需要等待5~10秒钟。
使用
ps -ax |grep natd|grep -v grep
就能知道了。如果没有发现进程了,就执行
natd -f /etc/natd.conf -n $eth
|
葱头 回复于:2003-11-05 09:24:06
|
如果就方便而言,我还是建议不要重新编译内核,而只需要修改/boot/defaults/loader.conf,添加ipf模块即可。
|
mornstar 回复于:2003-11-05 16:30:49
|
[quote:77087405e5="wangbin"][/quote:77087405e5]
BRIDGE enables bridging between ethernet cards -- see bridge(4).
You can use IPFIREWALL and DUMMYNET together with bridging.
|
kunrong 回复于:2003-11-05 16:51:48
|
[quote:5d99c01149="linyin"]放心,在这没人会笑你
大伙都是鸟鸟过来的[/quote:5d99c01149]
我是刚出生的鸟鸟。。。。。
|
release 回复于:2003-11-05 23:26:23
|
CU的人没这么坏吧!!
要是谁是这样,我帮你揍他!
|
葱头 回复于:2003-12-05 11:38:01
|
楼主对透明代理的概念不是很清楚,要么就是漏了一步,就是应该rdr重定向到squid服务器的端口,这样才是实现透明代理。
|
原文转自:http://www.ltesting.net
|