当前位置:操作系统 > Unix/Linux >>

FreeBSD服务器设置简明攻略

转载请保留作者信息 :葱头

  近段时间越来越多朋友利用FreeBSD强大的网络功能建立自己的服务器,在这过程中可能遇到了一些麻烦.为了大家少走弯路,这里力求简单说明一些常用服务的设置.

  基本网络设置:

  defaultrouter="192.168.0.1"

  gateway_enable="YES"

  hostname="xxxhost.xxxdomain.com"

  ifconfig_rl0="inet 192.168.0.1 netmask 255.255.255.0"

  注意: rl0为内网卡,你需要按你实际的网卡设备去写.

  一 如何在FreeBSD设置ADSL上网

  我曾经发表过一篇这样的文章,在这里我不在罗嗦了. 可以参考下面:

  如何在FreeBSD设置ADSL上网(在FreeBSD 4.4下测试通过)

  网上有部分关于FreeBSD设置ADSL上网的文章有些错误,这里公布葱头的设置文件。

  1。编辑/etc/ppp/ppp.conf 文件

  default:

  set log Phase tun command

  enable dns

  adsl:

  set device PPPoE: 设备名 ;即网卡的设备名

  set speed sync

  set mru 1492

  set mtu 1492

  set dial

  set login

  add default HISADDR

  set authname 帐户名

  set authkey 密码

  Papchap:

  set authname 帐户名

  set authkey 密码

  2。编辑/boot/defaults/loader.conf

  ng_pppoe_load="YES"

  虚拟拨号: ppp -background adsl

  测试: ifconfig -a 看到tun0伪设备捆绑了ISP分配的IP地址即成功

  如果想开机就自动拨号,那就要修改/etc/rc.conf,增加一下字段:

  ppp_enable="YES"

  ppp_mode="ddial"

  ppp_profile="adsl"

  二 设置缓冲型DNS

  1. 编辑/etc/resolv.conf

  domain xxxxx.com

  nameserver 127.0.0.1

  nameserver xxx.xxx.xxx.xxx.xxx

  nameserver xxx.xxx.xxx.xxx.xxx

  (后面两个一般在拨号时自动生成, 那是ISP的域名解析服务器地址. 127.0.0.1必须放在他们之前)

  2. 创建localhost.rev文件

  chmod 744 /etc/namedb/make-localhost (将脚本改为可执行)

  cd /etc/namedb

  ./make-localhost

  3.编辑/etc/namedb/named.conf

  options {

  directory "/etc/namedb";

  forward only;

  forwarders {

  xxx.xxx.xxx.xxx; xxx.xxx.xxx.xxx;

  };

  };

  zone "." {

  type hint;

  file "named.root";

  };

  zone "0.0.127.IN-ADDR.ARPA" {

  type master;

  file "localhost.rev";

  };

  注: 上面两个xxx.xxx.xxx.xxx就是/etc/resolv.conf 里面的两个nameserver地址

  4.修改/etc/rc.conf

  加入 named_enable="YES"

  三 设置透明代理

  这里假设你已经设置好squid并已投入使用,如果大家对squid不熟悉的话,我稍后会贴出squid的设置.

  一般网上都是用ipfw做防火墙的,但我觉得ipfilter较ipfw方便而且好用,所以这里采用ipfilter.

  1.编辑/boot/defaults/loader.conf

  在Networking modules段加入:

  ipl_load="YES"

  2.创建/etc/ipfilter.rules (ipfilter规则),这里仅仅给出一个例子,要根据自己的实际需求设定规则.

  block in log on 外网卡名 from any to any

  block out log on 外网卡名 from any to any

  pass out log on 外网卡名 proto icmp all keep state

  pass out log on 外网卡名 proto tcp/udp from any to any keep state

  pass in on 外网卡名 proto tcp from any to any port = ftp-data keep state

  pass in on 外网卡名 proto tcp from any port = ftp-data to any port > 1023 keep state

  pass in on 内网卡名 all

  pass out on 内网卡名 all

  block return-rst in log on 外网卡名 proto tcp from any to any flags S/SA

  block return-icmp(net-unr) in log on 外网卡名 proto udp from any to any

  3.创建/etc/ipnat.rules (NAT规则)

  rdr 内网卡名 0.0.0.0/0 port 80 -> 192.168.0.1 port 3128 tcp/udp

  注: 192.168.0.1 为内网卡ip地址, 并假设你的squid的端口为3128,不是的话改成实际的就可以了.

  4.编辑 /etc/rc.conf , 加入:

  ipfilter_enable="YES"

  ipfilter_rules="/etc/ipfilter.rules"

  ipnat_enable="YES"

  ipnat_rules="/etc/ipnat.rules"

  到这里为止,整个设置透明代理设置基本完成, 确保你的squid服务正常并开机自动启动. 然后重新启动服务器.将客户端电脑的网关和DNS服务器地址都改为内网卡ip地址(我那里是192.168.0.1) 就可以了.

  

上一个:FreeBSD5.0ADSL安装指南
下一个:FreeBSD系統升級

更多Unix/Linux疑问解答:
路由原理介绍
子网掩码快速算法
改变网络接口的速度和协商方式的工具miitool和ethtool
Loopback口的作用汇总
OSPF的童话
增强的ACL修改功能
三层交换机和路由器的比较
用三层交换机组建校园网
4到7层交换识别内容
SPARC中如何安装Linux系统(2)
SPARC中如何安装Linux系统(1)
用Swatch做Linux日志分析
实战多种Linux操作系统共存
浅析Linux系统帐户的管理和审计
Linux2.6对新型CPU的支持(2)
电脑通通透
玩转网络
IE/注册表
DOS/Win9x
Windows Xp
Windows 2000
Windows 2003
Windows Vista
Windows 2008
Windows7
Unix/Linux
苹果机Mac OS
windows8
安卓/Android
Windows10
如果你遇到操作系统难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,