quinta-feira, 8 de julho de 2010

Fazendo Backup Automatico com Mikrotik

set from=bkp@dominio.com.br password=senha23 server=servidordeemail username=bkp
#
# Backups automáticos via e-mail
#
/system script
remove bkp
remove envia
add name=envia_backup source={
#
# Configuracao
:gl email "bkp@seudominio.com.br"
:gl servidor "ip do servidor"
# Variaveis
:gl dia ([:pick [/system clock get date] 4 6])
:gl mes ([:pick [/system clock get date] 0 3])
:gl ano ([:pick [/system clock get date] 7 11])
:gl hora [/sys cl get time]
:gl rb [/sys id get name]
#:gl arquivo ($rb . "_" . $dia.$mes.$ano)
:gl arquivo ($rb . "_" . $mes)
#
:log info "Gerando backup..."
/system backup save name=$arquivo
#
# Aguarda um tempo para o Backup
:delay 30s
:log info "Enviando backup por e-mail..."
/tool e-mail send to="$email" subject=($rb . " \
".$dia.$mes.$ano . "-".$hora) from=$email file=$arquivo server=$servidor
/tool e-mail send to="bk@dominio.com.br" subject=($rb . " \
".$dia.$mes.$ano . "-".$hora) from=$email file=$arquivo server=$servidor
# Comentar a proxima linha SE for RouterOS < 4
#tls=yes
#
:log info "Backup terminado."
}
#
# Configurando o agendador de tarefas para envio a cada 5 dias, 5h
/sys scheduler
add name="envia_backup" on-event="backup" start-date=jan/01/1970 \
start-time=05:00:00 interval=5d disabled=no
#

Configurando BGP no Mikrotik

A configuração do BGP é bem simples no Mikrotik.



/routing bgp instance
set default as=99999 client-to-client-reflection=yes comment="" disabled=yes ignore-as-path-len=no name=default out-filter="" redistribute-connected=no \
redistribute-ospf=no redistribute-other-bgp=no redistribute-rip=no redistribute-static=no router-id=0.0.0.0
add as=55555 client-to-client-reflection=no comment="" disabled=no ignore-as-path-len=no name=bgp1 out-filter="" redistribute-connected=no redistribute-ospf=\
no redistribute-other-bgp=yes redistribute-rip=no redistribute-static=no router-id=200.200.200.200
/routing bgp aggregate
add advertise-filter="" attribute-filter="" disabled=yes inherit-attributes=no instance=bgp1 prefix=189.45.64.0/18 summary-only=yes suppress-filter=""
add advertise-filter="" attribute-filter="" disabled=yes inherit-attributes=no instance=bgp1 prefix=100.100.100.0/20 summary-only=yes suppress-filter=""
/routing bgp peer
add address-families=ip comment="" disabled=no hold-time=3m in-filter=AS99999-bgp-in instance=bgp1 multihop=no name=act nexthop-choice=default out-filter=\
AS99999-bgp-out remote-address=100.100.100.2 remote-as=99999 route-reflect=no tcp-md5-key="" ttl=255
add address-families=ip comment="" disabled=no hold-time=3m in-filter=operadora-in instance=bgp1 multihop=no name=operadora1 nexthop-choice=default out-filter="" \
remote-address=300.300.300.50 remote-as=88888 route-reflect=no tcp-md5-key="" ttl=255
add address-families=ip comment="" disabled=no hold-time=3m in-filter=AS88888-bgp-in instance=bgp1 multihop=no name=rnlink nexthop-choice=default out-filter=\
AS88888-bgp-out remote-address=400.400.400.2 remote-as=88888 route-reflect=no tcp-md5-key="" ttl=255


/routing filter
add action=accept bgp-as-path=99999 chain=AS99999-bgp-in comment="" disabled=no invert-match=no prefix=300.300.300.0/18 prefix-length=18-24
add action=discard chain=AS99999-bgp-in comment="" disabled=no invert-match=no
add action=accept bgp-as-path=88888 chain=AS88888-bgp-in comment="" disabled=no invert-match=no prefix=50.50.50.0/20 prefix-length=20-21
add action=discard chain=AS88888-bgp-in comment="" disabled=no invert-match=no
add action=discard bgp-as-path-length=!0-2 chain=AS88888-bgp-out comment="" disabled=no invert-match=no
add action=discard bgp-as-path-length=!0-2 chain=AS99999-bgp-out comment="" disabled=no invert-match=no
add action=discard bgp-as-path-length=!0-2 chain=operadora-in comment="" disabled=no invert-match=no