服务器搭建手册标准版之freebsd的上网共享设置

  • 安装freebsd

安装过程暂时略

  • 配置freebsd共享上网
  • 设置ppp拔号上网

#cd /etc/ppp

#vi ppp.conf  加下以下内容:

##################ppp.conf###########################################

default:

#set log Phase Chat LCP IPCP CCP tun command

ident user-ppp VERSION (built COMPILATIONDATE)

 

# Ensure that “device” references the correct serial port

#!  for your modem. (cuaa0 = COM1, cua a1 = COM2)

#

# set device /dev/cuaa1

set device PPPoE:rl1

 

#set speed 115200

set dial “ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \

\”\” AT OK-AT-OK ATE1Q0 OK \\dATDT\\T TIMEOUT 40 CONNECT”

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

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

set authname  gzDSL07128348@163.gd             # adsl user

set authkey   THFDBHNR         # adsl password

set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0

add default HISADDR

B、#vi /etc/ipfw.conf 加入以下内容:

##############TCP#############################

add 00001 deny log ip from any to any ipopt rr

add 00002 deny log ip from any to any ipopt ts

add 00003 deny log ip from any to any ipopt ssrr

add 00004 deny log ip from any to any ipopt lsrr

add 00005 deny tcp from any to any in tcpflags syn,fin

 

 

add 10001 allow tcp from any to 192.168.1.77 80 in

add 10002 allow tcp from any to 192.168.1.77 21 in

add 10003 allow tcp from any to 192.168.1.77 22 in

add 10004 allow tcp from any to 192.168.1.77 25 in

add 10005 allow tcp from any to 192.168.1.77 53 in

add 10006 allow tcp from any to 192.168.1.77 110 in

add 10007 allow tcp from any to 192.168.1.77 3306 in

add 10008 allow tcp from any to 192.168.1.77 10000 in

 

add 19997 check-state

add 19998 allow tcp from any to any out keep-state setup

add 19999 allow tcp from any to any out

 

########## UDP ##########

add 20001 allow udp from any 53 to 192.168.1.77

add 29999 allow udp from any to any out

 

C、编辑/etc/rc.conf 确保有下面内容

ifconfig_rl0=”inet 192.168.3.3 netmask 255.255.255.0″

ifconfig_rl1=”up”

firewall_enable=”YES”

firewall_script=”/etc/rc.firewall”

firewall_type=”/etc/ipfw.conf”

firewall_quiet=”YES”

firewall_logging_enable=”YES”

gateway_enable=”YES”

ppp_enable=”YES”

ppp_mode=”dedicated”

ppp_profile=”papchap”

ppp_profile=”default”

ppp_user=”root”

ppp_nat=”YES”

 

 

 

重启服务器

 

  • 支持FREEBSD ADSL断线自动重拔功能的设置。

===========ppp.conf======================

default:

#set log phase tun command

set ifaddr 10.0.0.1/0 10.0.0.2/0

adsl:

set device PPPoE:rl1

set reconnect 10 0

set timeout 10

set mru 1492

set mtu 1492

set authname gzDSL07128348@163.gd

set authkey THFDBHNR

set dial

set login

add default HISADDR

 

  • 修改conf的设置

ppp_enable=”YES”

ppp_mode=”ddial”

ppp_profile=”adsl”

ppp_user=”root”

ppp_nat=”YES”

 

  • 编辑sh脚本

=====================redial.sh=======================================

#!/bin/sh

 

offline=0

host2check=”202.96.134.134″

web2check=”http://www.google.com”

 

echo “Connecting $host2check …”

linktest=`ping -c3 $host2check |grep “bytes from”`

 

if [ ! -z “$linktest” ]; then

echo “$HOST is currently online.”

exit 0

fi

 

offline=`expr $offline + 1`

 

echo “Connecting $web2check …”

linktest=`fetch -q -o – $web2check |grep “logo.gif”`

 

if [ ! -z “$linktest” ]; then

echo “$HOST is currently online.”

exit 0

fi

 

offline=`expr $offline + 1`

 

if [ $offline = 2 ]; then

pid=`ps aux |grep ppp |awk ‘{print $2}’`

if [ ! -z “$pid” ]; then

pid=`echo $pid |awk ‘{print $1}’`

fi

 

ifunit=`ifconfig | grep tun | awk ‘{print $1}’ |sed ‘s/://’ |sed ‘s/tun//’`

ifunit=”unit$ifunit”

 

if [ ! -z “$pid” ]; then

kill -9 $pid

fi

 

echo “Reconnecting, please wait …”

/usr/sbin/ppp -quiet -ddial -nat -$ifunit adsl

sleep 6

 

linktest=`ping -c3 $host2check |grep “bytes from”`

if [ -z “$linktest” ]; then

echo “Something wrong with your Internet connection.”

exit 1

fi

fi

 

exit 0

 

  • 赋于sh权限

#chmod a+x redial.sh

 

  • 编辑 crontab 表

#crontab –e 加入以下内容

 

#5 * * * * /usr/home/gzzymh/redial.sh

以下文章点击率最高

Loading…

发表评论