- /etc/config/pptpd
#文件 #/etc/config/pptpd config service 'pptpd' option 'enabled' '1' option 'localip' '172.16.1.0' option 'remoteip' '172.16.1.10-100' #上面的remoteip为自动分配的ip地址范围,如需为某个用户指定IP地址 #需要在/etc/ppp/chap-secrets中指定 #如: user3 * pwd3 172.16.1.5 #此处指定的IP地址不应在上面的remoteip的范围内,否则会造成ip重复分配给不同的用户 config 'login' option 'username' 'user1' option 'password' 'pwd1' config 'login' option 'username' 'user2' option 'password' 'pwd2' #此文件为pptpd服务启动时所解析的配置文件 #启动pptpd服务时,启动脚本将解析此文件后 将内容写入到其它相关文件 #如将login段写入文件/etc/ppp/chap-secrets #注意,每启动一次将会写入一次.
如果想支持这个配置
config 'login' option 'username' 'user2' option 'password' 'pwd2' option 'remoteip' '172.16.1.5'
需要修改/etc/init.d/pptpd文件
#!/bin/sh /etc/rc.common # Copyright (C) 2015 OpenWrt.org START=60 USE_PROCD=1 BIN=/usr/sbin/pptpd CONFIG=/var/etc/pptpd.conf CHAP_SECRETS=/var/etc/chap-secrets OPTIONS_PPTP=/var/etc/options.pptpd validate_login_section() { uci_validate_section pptpd login "" \ 'username:string' \ 'password:string' \ 'remoteip:string:*' #'remoteip:string:*'这行是新添加的,让他能读取remoteip荐 } validate_pptpd_section() { uci_validate_section pptpd service "" \ 'enabled:uinteger' \ 'localip:string' \ 'remoteip:string' \ 'mppe:list(string):required no40 no56 stateless' \ 'logwtmp:uinteger' } setup_login() { validate_login_section "" || { echo "validation failed -setup_login" return 1 } [ -n "${username}" ] || return 0 [ -n "${password}" ] || return 0 #这行注释掉,不使用追加 #echo "${username} pptp-server ${password} ${remoteip} " >> $CHAP_SECRETS #替换为 在第1行添加 sed -i "1i${username} pptp-server ${password} ${remoteip}" $CHAP_SECRETS } setup_config() { local enabled localip remoteip mppe validate_pptpd_section "" || { echo "validation failed -setup_config" return 1 } [ "$enabled" -eq 0 ] && return 1 mkdir -p /var/etc cp /etc/pptpd.conf $CONFIG cp /etc/ppp/options.pptpd $OPTIONS_PPTP [ -n "$localip" ] && echo "localip $localip" >> $CONFIG [ -n "$remoteip" ] && echo "remoteip $remoteip" >> $CONFIG [ "$logwtmp" -eq 1 ] && echo "logwtmp" >> $CONFIG echo "mppe $(echo $mppe | sed -e 's/\s/,/g')" >> $OPTIONS_PPTP return 0 } start_service() { config_load pptpd setup_config pptpd || return #新添加,先删除chap-secrets文件中原有的用户信息行,只删除pptp-server的配置,其它配置不处理 sed -i -e '/pptp-server/d' $CHAP_SECRETS config_foreach setup_login login ln -sfn $CHAP_SECRETS /etc/ppp/chap-secrets procd_open_instance procd_set_param command $BIN -c $CONFIG --fg -o $OPTIONS_PPTP procd_close_instance }
防火墙自定义规则
#PPTP VPN防火墙-转发 iptables -A input_rule -i ppp+ -j ACCEPT iptables -A output_rule -o ppp+ -j ACCEPT # This rule will allow traffic towards internet iptables -A forwarding_rule -i ppp+ -j ACCEPT iptables -A forwarding_rule -o ppp+ -j ACCEPT
100