前言
使用freeBSD进行拨号上网,地址分配实现。
一、系统版本及软件
系统:freeBSD 13.0
dhcp服务器:isc-dhcp44-server
二、PPPoE拨号配置
1.配置文件
主要配置文件及路径:
/etc/ppp/ppp.conf 拨号配置
/etc/rc.conf 开机自动拨号
2.配置内容
拨号配置
cd /etc/ppp/ppp.conf
default:
set log Phase Chat LCP IPCP CCP tun command #日志
#ident user-ppp VERSION
# Ensure that "device" references the correct serial port
# for your modem. (cuau0 = COM1, cuau1 = COM2)
#
set device PPPoE:em0 #em0为设备接口名称
#set speed 115200
set speed sync # 速度设置
#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)
papchap: #此名称可自行更改
#
# edit the next three lines and replace the items in caps with
# the values which have been assigned by your ISP.
#
#set phone PHONE_NUM
set authname USERNAME #宽带账号
set authkey PASSWORD #宽带密码
set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0
add default HISADDR # Add a (sticky) default route 默认即可
手动拨号: ppp -ddial papchap
开机自动拨号
cd /etc/rc.conf
#设备其他配置
hostname="mnos.com"
ifconfig_em0="DHCP"
ifconfig_igb1="10.8.1.194/24"
sshd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
#自动拨号配置
gateway_enable= "YES"
ppp_enable="YES"
ppp_mode="ddial"
ppp_nat="YES"
ppp_profile="papchap" #/etc/ppp/ppp.conf 中自定义配置的名称
到此重启即可拨号上网
三、DHCP服务器
1.安装
pkg install isc-dhcp44-server
2.配置文件
/usr/local/etc/dhcpd.conf
/etc/rc.conf
3.配置内容
DHCP服务器配置
cd /usr/local/etc/dhcpd.conf
...
option domain-name "unixcop.com"; #分配地址DNS后缀名,可注释掉
option domain-name-servers 223.5.5.5; #分配DNS
#租约设置
default-lease-time 3600;
max-lease-time 86400;
ddns-update-style none;
...
#添加地址池
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.199; #可分配地址
option routers 192.168.1.1; #网关
}
手动启动:/usr/local/etc/rc.d/isc-dhcpd start
DHCP状态:/usr/local/etc/rc.d/isc-dhcpd status
开机自启动配置
#设备其他配置
hostname="mnos.com"
ifconfig_em0="DHCP"
ifconfig_igb1="10.8.1.194/24"
sshd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
syslogd_flags="-ss"#系统日志
#自动拨号配置
gateway_enable= "YES"
ppp_enable="YES"
ppp_mode="ddial"
ppp_nat="YES"
ppp_profile="papchap" #/etc/ppp/ppp.conf 中自定义配置的名称
#DHCP开机自启配置
ifconfig_igb0="192.168.1.1/24 up"
#defaultrouter="192.168.1.1"
sendmail_enable="NONE"
dhcpd_enable="YES"
dhcpd_ifaces="igb0" #作用接口
分配地址查看:cat /var/db/dhcpd/dhcpd.lease
四、总结
到此使用freeBSD可以自动拨号上网并可以为客户机分配IP地址。