| Развертывание биллинга для небольшой сети с нуля Stargazer + Ubilling |
|
| Автор: Administrator | |
| 27.11.11 09:34 | |
|
Развертывание биллинга для небольшой сети с нуля Stargazer + Ubilling ( есть поддержка Украинского языка ) demo: http://ubilling.net.ua/?module=fnpages&pid=demo Кабинет пользователя: http://demo.ubilling.net.ua:9999/billing/userstats/index.php
Предыстория: # cd /usr/ports/databases/mysql51-server/ && make install # cd /usr/ports/textproc/expat2 && make install # cd /usr/ports/devel/libtool && make all && make install # cd /usr/ports/security/sudo && make install
# cd /usr/ports/net/isc-dhcp31-server/ && make install
# cd /usr/ports/lang/php5 && make install
# cd /usr/ports/lang/php5-extensions/ && make config && make install
# fetch http://stg.dp.ua/download/server/2.407-p1/stg-2.407-p1.tar.gz
# cd /usr/local/www/data/ # mkdir billing # cd billing # fetch http://ubilling.net.ua/ub.tgz # tar zxvf ub.tgz # chmod -R 777 content/ config/ multinet/ exports/ remote_nas.conf vservices.php
# mkdir /etc/stargazer/dn # chmod -R 777 /etc/stargazer/dn # ln -fs /usr/local/www/data/billing/multinet /usr/local/etc/multinet # ln -fs /usr/local/www/data/billing/remote_nas.conf /etc/stargazer/remote_nas.conf # ln -fs /etc/stargazer/dn /usr/local/www/data/billing/content/dn
# /usr/local/etc/rc.d/mysql-server start # /usr/local/etc/rc.d/apache onestart
LogFile = /var/log/stargazer.log
PIDFile = /var/run/stargazer.pid
Rules = /etc/stargazer/rules
DetailStatWritePeriod = 1/4
StatWritePeriod = 10
DayFee = 1
DayFeeIsLastDay = no
DayResetTraff = 1
SpreadFee = no
FreeMbAllowInet = no
WriteFreeMbTraffCost = yes
FullFee = yes
<DirNames>
DirName0 = Internet
DirName1 =
DirName2 =
DirName3 =
DirName4 =
DirName5 =
DirName6 =
DirName7 =
DirName8 =
DirName9 =
</DirNames>
ExecutersNum = 1
ModulesPath = /usr/lib/stg
<StoreModule store_mysql>
dbhost = localhost
dbname = stg
dbuser = root
rootdbpass = newpassword
</StoreModule>
<Modules>
<Module auth_ao>
</Module>
<Module auth_ia>
Port = 5555
UserDelay = 60
UserTimeout = 65
FreeMb = cash
</Module>
<Module conf_sg>
Port = 5555
</Module>
<Module cap_nf>
TCPPort = 42111
UDPPort = 42111
</Module>
<Module remote_script>
SendPeriod = 10
SubnetFile =/etc/stargazer/remote_nas.conf
Password = пароль_для_rscriptd
UserParams=Cash Tariff
Port = 9999
</Module>
</Modules>
# echo "ALL 0.0.0.0/0 DIR0" > /etc/stargazer/rules
# echo "172.16.0.0/18 172.16.0.2" > /etc/stargazer/remote_nas.conf
# stargazer # killall stargazer
# mysql -u root -p stg -e "S Enter password: +---------------+ | Tables_in_stg | +---------------+ | admins | | messages | | stat | | tariffs | | users | +---------------+
User_Alias BILLING = www BILLING ALL = NOPASSWD: ALL
# cd /usr/local/www/data/billing/ # cat docs/test_dump.sql | mysql -u root -p stg
#mysql -u root -p stg -e "SHOW TABLES" Enter password: +-----------------+ | Tables_in_stg | +-----------------+ | address | | admins | | ahenassign | | apt | | build | | cardbank | | cardbrute | | cashtype | | cfitems | | cftypes | | city | | contracts | | contrahens | | cpe | | cpetypes | | dhcp | | directions | | dshape_time | | emails | | employee | | jobs | | jobtypes | | messages | | modem_templates | | modems | | nas | | nethosts | | networks | | notes | | payments | | phones | | realname | | services | | servtariff | | speeds | | stat | | street | | switches | | switchmodels | | tags | | tagtypes | | tariffs | | taskman | | userreg | | users | | userspeeds | | vcash | | vcashlog | | vservices | | weblogs | +-----------------+
baseconf = sgconfxml SGCONF=/usr/sbin/sgconf SGCONFXML=/usr/sbin/sgconf_xml STG_HOST=localhost STG_PORT=5555 XMLRPC_PORT=8081 STG_LOGIN=admin STG_PASSWD=новый_пароль_админа_stargazer SUDO=/usr/local/bin/sudo TOP = /usr/bin/top -b CAT=/bin/cat GREP=/usr/bin/grep RC_DHCPD=/usr/local/etc/rc.d/isc-dhcpd UPTIME=/usr/bin/uptime PING=/sbin/ping KILL=/bin/kill STGPID=/var/run/stargazer.pid STGNASHUP=1 PHPSYSINFO=phpsysinfo/ LANG = ua TASKBAR_ICON_SIZE = 128 REGRANDOM_MAC=1 REGALWONLINE=1 REGDISABLEDSTAT=1
# cp -f docs/presets/FreeBSD/etc/stargazer/config /etc/stargazer/ # cp -f docs/presets/FreeBSD/etc/stargazer/GetMac /etc/stargazer/ # chmod a+x /etc/stargazer/*
#!/bin/sh LOGIN=$1 IP=$2 CASH=$3 ID=$4 MAC=`php /etc/stargazer/GetMac $LOGIN` /usr/sbin/arp -S $IP $MAC
host = localhost username = root password = newpassword database = stg
;database host server = "localhost" ;database port port = "3306" ;user login username = "root" ;user password password = "newpassword" ;database name to use db = "stg" character = "UTF8" prefix = "billing"
# stargazer # sgconf_xml -s localhost -p 5555 -a admin -w 123456 -r "<ChgAdmin Login=\"admin\" Password=\"
gateway_enable="YES" hostname="billing.isp" ifconfig_em0="inet 172.16.0.1 netmask 255.255.192.0" inetd_enable="YES" keymap="ru.koi8-r" sshd_enable="YES" named_enable="YES" sendmail_enable="NO" mysql_enable="YES" apache_enable="YES" dhcpd_enable="YES" dhcpd_flags="-q" dhcpd_conf="/usr/local/etc/multinet/dhcpd.conf" dhcpd_ifaces="em0"
acl internals { 172.16.0.0/18; };
acl local { 127.0.0.1; };
zone "isp" {
type master;
file "/etc/namedb/master/isp";
allow-query { internals; local; };
};
$TTL 86400
@ IN SOA isp. admin.isp. (
2011101001 ; Serial
8H ; Refresh
1D ; Retry
2W ; Expire
1D ) ; Negative Cache TTL
IN NS dns.isp.
@ IN A 172.16.0.1
billing IN A 172.16.0.1
stat IN A 172.16.0.1
nas1 IN A 172.16.0.2
#!/bin/sh /usr/sbin/stargazer
# chmod a+x /etc/rc.d/billing
NameVirtualHost *:80 <VirtualHost *:80> ServerName billing.isp DocumentRoot "/usr/local/www/data/billing/" AddDefaultCharset utf-8 </VirtualHost> <VirtualHost *:80> ServerName stat.isp DocumentRoot "/usr/local/www/data/billing/userstats/" AddDefaultCharset utf-8 </VirtualHost>
option domain-name "isp";
option domain-name-servers 172.16.0.1;
default-lease-time 3600;
max-lease-time 43200;
authoritative;
ddns-update-style none;
log-facility local7;
one-lease-per-client true;
deny duplicates;
shared-network ourisp {
{SUBNETS}
}
subnet {NETWORK} netmask {MASK} {
default-lease-time 3600;
option domain-name "ourisp";
option subnet-mask {MASK};
option routers 172.16.0.2;
include "/usr/local/etc/multinet/{HOSTS}";
}
# cd /usr/src/sys/i386/conf/ # cp GENERIC NAS1
options IPFIREWALL options IPFIREWALL_DEFAULT_TO_ACCEPT options IPFIREWALL_FORWARD options IPFIREWALL_VERBOSE options IPFIREWALL_VERBOSE_LIMIT=50 options IPFIREWALL_NAT options LIBALIAS options ROUTETABLES=2 options DUMMYNET
# config NAS1 && cd ../compile/NAS1 && make cleandepend && make depend && make && make install
defaultrouter="1.2.3.3" gateway_enable="YES" hostname="nas1" ifconfig_em1="inet 1.2.3.4 netmask 255.255.255.0 -rxcsum -txcsum -tso" ifconfig_em0="inet 172.16.0.2 netmask 255.255.192.0 -rxcsum -txcsum -tso" inetd_enable="YES" sshd_enable="YES" firewall_enable="YES" firewall_nat_enable="YES" dummynet_enable="YES" firewall_script="/etc/firewall.conf" thttpd_enable="YES" thttpd_enable="YES"
# cd /usr/ports/www/thttpd/ && make install
# cd /usr/ports/net-mgmt/softflowd/ && make install
#cd /usr/ports/textproc/expat2 && make install
# cd /usr/ports/net-mgmt/bandwidthd/ && make install
# cd /usr/ports/lang/php5 && make install
# cd /usr/ports/lang/php5-extensions/ && make config && make install
#!/bin/sh
# отправляем netflow на биллинговый сервер
/usr/local/sbin/softflowd -i em0 -n 172.16.0.1:42111
FwCMD="/sbin/ipfw -q"
${FwCMD} -f flush
#сеть пользователей
${FwCMD} table 2 add 172.16.0.0/18
#сети которые не будем NAT-ить
${FwCMD} table 9 add 1.2.3.4/24
#NAT
${FwCMD} nat 1 config log if em1 reset same_ports
${FwCMD} add 600 nat 1 ip from table\(2\) to not table\(9\) via em1
${FwCMD} add 601 nat 1 ip from any to 1.2.3.4 via em1
#политика блокирования по умолчанию
${FwCMD} add 65533 deny all from table\(2\) to any via em0
${FwCMD} add 65534 deny all from any to table\(2\) via em0
${FwCMD} add 65535 allow all from any to any
# chmod a+x /etc/firewall.conf
#!/bin/sh /usr/sbin/rscriptd
#chmod a+x /etc/rc.d/rscriptd
# mkdir ubilling && fetch http://ubilling.net.ua/ub.tgz && tar zxvf ub.tgz && cd ubilling # mkdir /etc/stargazer/dn && chmod a+w /etc/stargazer/dn # cp -f docs/presets/FreeBSD/etc/stargazer/* /etc/rscripd/ # chmod a+x /etc/rscriptd/*
IFACE="em0"
subnet 172.16.0.0/18 dev "em0" output_cdf true recover_cdf true
3 3 * * * /bin/kill -HUP `cat /var/run/bandwidthd.pid`
# mv /usr/local/bandwidthd/htdocs /usr/local/www/data/band # ln -fs /usr/local/www/data/band/ /usr/local/bandwidthd/htdocs # cp /usr/local/etc/thttpd.conf.sample /usr/local/etc/thttpd.conf
# /usr/local/bandwidthd/bandwidthd # /usr/local/etc/rc.d/thttpd start
net.inet.ip.fw.one_pass=1 net.inet.ip.fastforwarding=1 net.inet.tcp.nolocaltimewait=1
оригинал: http://habrahabr.ru/blogs/sysadm/130937/ ссылка на статью: http://thin.kiev.ua/index.php?option=com_content&view=article&id=459:ubilling&catid=39:linux&Itemid=63 видео: Ubilling rev.306{jcomments on} |
|
| Последнее обновление 09.04.12 09:02 |