ставим mpd5, fping
ee /usr/local/etc/mpd5/mpd.conf
startup:
# configure mpd users
set user login pass
# configure the console
set console self 0.0.0.0 5005
set console open
# configure the web server
set web self 0.0.0.0 5006
set web open
default:
load PPPoE
PPPoE:
create bundle static B1
# set iface route default
set ipcp ranges 0.0.0.0/0 0.0.0.0/0
set ipcp yes vjcomp
set iface disable on-demand
set iface idle 0
set iface enable tcpmssfix
#set link disable multilink
#set link no acfcomp protocomp
#set iface up-script /usr/local/etc/ip-world.sh
#set iface down-script /usr/local/etc/ipd-world.sh
create link static L1 pppoe
set link action bundle B1
set auth authname
xxxxx@dsl.ukrtel.net
set auth password xxxxx
set link max-redial 0
set link mtu 1492
set link keep-alive 10 60
set pppoe iface интерфейс сетевой карты
set pppoe service "Ukrtel"
open
ee /usr/local/etc/route_fping
#!/usr/bin/perl
require 'open2.pl';
$pid = &open2("OUTPUT","INPUT","/usr/local/sbin/fping -u");
@check=("проверяемый айпи-адрес");
foreach(@check) { print INPUT "$_\n"; }
close(INPUT);
@output=<OUTPUT>;
if ($#output != -1) {
`/usr/local/etc/rc.d/mpd5 restart`;
sleep 2;
print "Передергиваем \n";
};
Нат можно настроить в самом мпд, но у меня сделано отдельным natd
В файерволе ipfw
# Divert natd
${fwcmd} add 530 divert natd ip from any to any via интерфейс
# Pass all
${fwcmd} add 600 allow all from any to any
ee /etc/natd.conf
use_sockets yes
dynamic yes
same_ports yes
redirect_port tcp ip
ort port для форвардинга
ee /usr/local/etc/traf.sh
#!/bin/sh
natdd=`sockstat | grep 8668 | cut -f 6 -d " "`
if [ "$natdd" != "natd" ]
then
echo "Перезапуск natd"
/etc/rc.d/natd restart
else
echo "natd поднят"
fi
ee /etc/crontab
* * * * * root /usr/local/etc/traf.sh
*/5 * * * * root /usr/local/etc/route_fping