Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1437003
  • 博文数量: 463
  • 博客积分: 10540
  • 博客等级: 上将
  • 技术积分: 5450
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-12 08:30
文章分类

全部博文(463)

文章存档

2014年(2)

2012年(14)

2011年(42)

2010年(18)

2009年(78)

2008年(35)

2007年(182)

2006年(92)

我的朋友

分类: BSD

2006-11-12 09:31:29

()     安装配置........................................................................................................ 1


()     设定PPPoE拨号............................................................................................. 2


()     增加静态路由表.............................................................................................. 3


()     设定IPFW防火墙........................................................................................... 3


()     FB5.4ADSL网关实例................................................................................. 7


()     FB+ipfilter实现整网透明代理上网................................................................... 9


()     邮件服务器安装与设置................................................................................. 20


()     etc下文件说明:.......................................................................................... 28


()     web服务器配置............................................................................................ 40


 



 


1、安装


    可通过sysinstall安装与配置系统


    安装软件:/usr/ports/下进行安装 make make installmake clean


        注:更新ports命令如下:


cvsup -gL 2 -h cvsup.freebsdchina.org /usr/share/examples/cvsup/ports-supfile


 2、网络与服务


      可在/etc/rc.conf中设定,


      /etc/rc.d/下为各种服务程序 /etc/rc.d/xxx restart


      启动网络为:/etc/netstart


 


拨号


1、设定/etc/ppp/ppp.conf


 


default:


 set log Phase Chat LCP IPCP CCP tun command


 ident user-ppp VERSION (built COMPILATIONDATE)


 set device PPPoE:rl1


 set mru 1492


 set mtu 1492


 #set ctsrts off


 set speed sync


 set timeout 30                    # 3 minute idle timer (the default)


 #disable lqr


 #deny lqr


 add default HISADDR                # Add a (sticky) default route


 enable dns                          # request DNS info (for resolv.conf)


 


 


pppoe:


 set authname dgc25454l99@163.gd


 set authkey dg1234


 set dial


 set login


 #set ifaddr 10.0.0.1/0 10.0.0.2/0


 set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0


 nat enable yes


 


ppp -ddial pppoe


 


 


2/etc/rc.conf:


 


 


ppp_enable="YES"


ppp_mode="ddial"


ppp_profile="pppoe"


ppp_nat="YES"


named_enable="yes"


 


gateway_enable=”YES”


 


natd_interface="tun0"         #连接ADSL的接口
natd_enable="YES"              #
启用nat


 


 


注:gateway_enable=”YES”  相当于在/etc/sysctl.conf中加入net.inet.ip.forwarding=1或使用命令:


sysctl –w net.inet.ip.forwarding=1


 



 



 


修改/etc/rc.conf文件,加入如下类似语句:


 


static_routes="net1 net2"


route_net1="-net 192.168.0.0/24 192.168.2.254"


route_net2="-net 192.168.1.0/24 192.168.2.253"


 


 


防火墙


 


1、编辑器编辑/etc/rc.conf


加入如下参数:


firewall_enable="YES"   激活Firewall防火墙


firewall_script="/etc/rc.firewall"   Firewall防火墙的默认脚本


firewall_type="/etc/ipfw.conf"   Firewall自定义脚本


firewall_quiet="NO"  启用脚本时,是否显示规则信息;假如你的防火墙脚本已经不会再有修改,那么就可以把这里设置成“YES”了。


firewall_logging_enable="YES"  启用FirewallLog记录


2、编辑/etc/syslog.conf文件


在文件最后加入如下内容:


!ipfw


*.* /var/log/ipfw.log


这行的作用是将IPFW的日志写到/var/log/ipfw.log文件里,当然,你也可以为日志文件指定其他目录。


 


3ipfw常用命令


ipfw show显示当前规则情况


ifw list显示规则


ipfw flush刷新规则


ipfw的规则号小的优生执行,最后是65535(默认所有都拒绝)


ipfw add [rule] 新增一条规则。规则 (rule) 的语法请参考下一节的说明。
ipfw delete [number]
删除一条编号为 number 的规则。

ipfw -f flush
清除所有的规则。

ipfw zero
将计数统计归零。

ipfw list
列出现在所有规则,可以配合下列参数使用。

-a
使用 list 时,可以列出封包统计的数目。

-f
不要提出确认的询问。

-q
当新增 (add)、归零(zero)、或清除 (flush) 时,不要列出任何回应。当使用远程登入,以 script ( sh /etc/rc.firewall) 来修改防火墙规则时,内定会列出你修改的规则。但是当下了 flush 之后,会立即关掉所有联机,这时候响应的讯息无法传达终端机,而规则也将不被继续执行。此时唯一的方法就是回到该计算机前重新执行了。在修改防火墙规则时,最好在计算机前修改,以免因为一个小错误而使网络联机中断。

-t
当使用 list 时,列出最后一个符合的时间。

-N
在输出时尝试解析 IP 地址及服务的名称。

-s [field]
当列出规则时,依哪一个计数器 (封包的数量、位数、记录的数量及时间) 来排序。


 


 


语法示例:


ipfw add 10001 deny all from 218.24.22.22 to any


拒绝来自218.249.20.135的任何服务


 


ipfw add 50000 fwd 127.0.0.1,3128 tcp from 192.168.1.0/24 to any 80 一般用于设置透明代理


 


限制带宽


ipfw add pipe 1 ip from 192.168.0.1/24 to any in
ipfw pipe 1 config bw 20KBytes/s


 


ipfw规则详细资料:


 


4/etc/rc.firewall样例:


 


vi /etc/rc.firewall


 


# 设定我的 IP
myip="1.2.3.4"
#
设定对外的网络卡代号
outif="vr0"
#
设定对内的网络上代号
inif="vr1"
#
清除所有的规则
/sbin/ipfw -f flush
# Throw away RFC 1918 networks
${ipfw} add deny ip from 10.0.0.0/8 to any in via ${oif}
${ipfw} add deny ip from 172.16.0.0/12 to any in via ${oif}
${ipfw} add deny ip from 192.168.0.0/16 to any in via ${oif}
#
只允许内部网络对 192.168.0.1 使用 telnet 服务
/sbin/ipfw add 200 allow tcp from 192.168.0.1/24 to 192.168.0.1 telnet
#
拒绝其它人连到 port 23,并记录尝试联机的机器
/sbin/ipfw add 300 deny log tcp from any to me 23
#
拒绝任何 ICMP 封包
/sbin/ipfw add 400 deny icmp from any to any


# 下面这台机器是坏人,不让它进来,并记录下来
/sbin/ipfw add 1100 deny log all from 211.21.104.102 to any
# NAT
的设定
/sbin/ipfw add divert natd all from any to any via vr0
#
限制内部网域对外下载最大频宽为 20KBytes/s,上传最大频宽为 5KBytes/s
ipfw pipe 20 config bw 20KBytes/s
ipfw add pipe 20 ip from any to 192.168.0.1/24 out
ipfw pipe 30 config bw 5KBytes/s
ipfw add pipe 30 ip from 192.168.0.1/24 to any in
#
允许本机对任何地方联机
/sbin/ipfw add check-state
/sbin/ipfw add 2000 allow udp from ${myip} to any keep-state
/sbin/ipfw add 2100 pass ip from ${myip}

阅读(1000) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~