#Explicação ao ifstated para não haver mais duvidas !
#Ativa o Log no /var/log/messages
loglevel debug
# Seta o estado inicial sendo assim ele executara o segundo estado abaixo
init-state link1_down
# Variável para definir o método de teste
# E criado uma rota estatica para o site resgistro.br saindo pelo primeiro link
rede_link1='"ping -c 5 -i 1 -t 5 -q 200.160.2.3 > /dev/null" every 20'
# Primeiro estado, se nao pingar ele vai executar este script que troca a rota default
# e carrega o arquivo de pf-link2.conf
state link1_up {
if ! $rede_link1
{
run "/bin/sh /usr/local/bin/link2.sh"
set-state link1_down
}
}
# O Segundo estado, ja e executado logo de inicio quando o link1 esta UP
# colocando o default gateway, setando uma rota estática para o ip do registro.br
# e carregando o arquivo de pf.conf padrão
state link1_down {
if $rede_link1
{
run "/bin/sh /usr/local/bin/link1.sh"
set-state link1_up
}
}
# Quando voltar a pingar o site resgistro.br indica que o link voltou a funcionar
# e o primeiro estado fica sendo o em execução
Minha vida no Linux
Site de um analista de suporte técnico, para dicas que considero difíceis de achar na internet.
sexta-feira, 14 de agosto de 2009
sexta-feira, 29 de maio de 2009
Configurar VirtualBox para o Mundo!!!
A única forma que consegui fazer o VirtualBox se comunicar com o Mundo, o que ele chama de "Placa em modo Bridge". Esse procedimento foi feito no Ubuntu 9.04.
Instalar os pacotes:
$ sudo apt-get install bridge-utils uml-utilities
Você tem que adcionar o seu usuário ao grupo uml-net
$ sudo gpasswd -a uml-net filipi
(troque o filipi para o nome do seu usuário que esta executando o VB)
No arquivo de interfaces de rede faça isso:
$ sudo vim /etc/network/interfaces
auto tap0
iface tap0 inet manual
up ifconfig $IFACE 0.0.0.0 up (sim o ip fica 0.0.0.0!)
down ifconfig $IFACE down
tunctl_user filipi (mesma coisa, altere para o seu usuário)
auto br0
iface br0 inet static
address xxx.xxx.xxx.xxx (coloque um ip válido da rede interna)
netmask xxx.xxx.xxx.xxx (coloque o netmask da sua rede interna)
gateway xxx.xxx.xxx.xxx (coloque o gateway da sua rede interna)
bridge_ports eth0 tap0
Reiniciar o serviço
$ sudo /etc/init.d/networking restart
No Virtual box altera a configuração de rede desta forma:
Dentro da sua máquina virtual configure um OUTRO ip válido para sua rede assim como a netmask e o gateway, pronto tudo funcionou.
Obs.: A interface eth0 fica sem IP, pois você ligou na br0 as duas interfaces.
Instalar os pacotes:
$ sudo apt-get install bridge-utils uml-utilities
Você tem que adcionar o seu usuário ao grupo uml-net
$ sudo gpasswd -a uml-net filipi
(troque o filipi para o nome do seu usuário que esta executando o VB)
No arquivo de interfaces de rede faça isso:
$ sudo vim /etc/network/interfaces
auto tap0
iface tap0 inet manual
up ifconfig $IFACE 0.0.0.0 up (sim o ip fica 0.0.0.0!)
down ifconfig $IFACE down
tunctl_user filipi (mesma coisa, altere para o seu usuário)
auto br0
iface br0 inet static
address xxx.xxx.xxx.xxx (coloque um ip válido da rede interna)
netmask xxx.xxx.xxx.xxx (coloque o netmask da sua rede interna)
gateway xxx.xxx.xxx.xxx (coloque o gateway da sua rede interna)
bridge_ports eth0 tap0
Reiniciar o serviço
$ sudo /etc/init.d/networking restart
No Virtual box altera a configuração de rede desta forma:
Dentro da sua máquina virtual configure um OUTRO ip válido para sua rede assim como a netmask e o gateway, pronto tudo funcionou.
Obs.: A interface eth0 fica sem IP, pois você ligou na br0 as duas interfaces.
quarta-feira, 13 de maio de 2009
Cliente Openvpn Ubuntu 9.04 (Jaunty Jackalope)
Configurando um cliente openvpn com o Ubuntu 9.04:
Teve que ser na mão mesmo.
$sudo apt-get install gadmin-openvpn-client
Você vai precisar dos certificados gerados no servidor (exemplos: filipi.crt filipi.key ca.crt e a dh1024.pem este último é os parâmetros do Diffie Hellman que foram gerados também no servidor)
Coloque tudo na mesma pasta com o arquivo de configuração vpn.ovpn: (Vou colocar o arquivo completo com os comentários)
# Edit this file, and save to a .ovpn extension
# so that OpenVPN will activate it when run
# as a service.
client
# Change 'myremote' to be your remote host,
# or comment out to enter a listening
# server mode..
remote grupoifm.no-ip.info
# Uncomment this line to use a different
# port number than the default of 1194.
; port 1194
# Choose one of three protocols supported by
# OpenVPN. If left commented out, defaults
# to udp.
; proto [tcp-server | tcp-client | udp]
# You must specify one of two possible network
# protocols, 'dev tap' or 'dev tun' to be used
# on both sides of the connection. 'tap' creates
# a VPN using the ethernet protocol while 'tun'
# uses the IP protocol. You must use 'tap'
# if you are ethernet bridging or want to route
# broadcasts. 'tun' is somewhat more efficient
# but requires configuration of client software
# to not depend on broadcasts. Some platforms
# such as Solaris, OpenBSD, and Mac OS X only
# support 'tun' interfaces, so if you are
# connecting to such a platform, you must also
# use a 'tun' interface on the Windows side.
# Enable 'dev tap' or 'dev tun' but not both!
dev tun
# This is a 'dev tap' ifconfig that creates
# a virtual ethernet subnet.
# 10.3.0.1 is the local VPN IP address
# and 255.255.255.0 is the VPN subnet.
# Only define this option for 'dev tap'.
#ifconfig 10.3.0.1 255.255.255.0
#ifconfig 10.3.0.1 255.255.255.0
# This is a 'dev tun' ifconfig that creates
# a point-to-point IP link.
# 10.3.0.1 is the local VPN IP address and
# 10.3.0.2 is the remote VPN IP address.
# Only define this option for 'dev tun'.
# Make sure to include the "tun-mtu" option
# on the remote machine, but swap the order
# of the ifconfig addresses.
;tun-mtu 1500
;ifconfig 10.3.0.1 10.3.0.2 10.3.0.5
# If you have fragmentation issues or misconfigured
# routers in the path which block Path MTU discovery,
# lower the TCP MSS and internally fragment non-TCP
# protocols.
;fragment 1300
;mssfix
# If you have set up more than one TAP-Win32 adapter
# on your system, you must refer to it by name.
;dev-node my-tap
# You can generate a static OpenVPN key
# by selecting the Generate Key option
# in the start menu.
#
# You can also generate key.txt manually
# with the following command:
# openvpn --genkey --secret key.txt
#
# key must match on both ends of the connection,
# so you should generate it on one machine and
# copy it to the other over a secure medium.
# Place key.txt in the same directory as this
# config file.
;secret key.txt
# Uncomment this section for a more reliable
# detection when a system loses its connection.
# For example, dial-ups or laptops that travel
# to other locations.
#
# If this section is enabled and "myremote"
# above is a dynamic DNS name (i.e. dyndns.org),
# OpenVPN will dynamically "follow" the IP
# address of "myremote" if it changes.
; ping-restart 60
; ping-timer-rem
; persist-tun
; persist-key
; resolv-retry 86400
# keep-alive ping
ping 10
# enable LZO compression
comp-lzo
# moderate verbosity
verb 7
mute 10
tls-client
dh dh1024.pem
ca ca.crt
cert filipi.crt
key filipi.key
Para se conectar execute o comando:
openvpn --config vpn.ovpn
Pronto, conectou !!!!
Teve que ser na mão mesmo.
$sudo apt-get install gadmin-openvpn-client
Você vai precisar dos certificados gerados no servidor (exemplos: filipi.crt filipi.key ca.crt e a dh1024.pem este último é os parâmetros do Diffie Hellman que foram gerados também no servidor)
Coloque tudo na mesma pasta com o arquivo de configuração vpn.ovpn: (Vou colocar o arquivo completo com os comentários)
# Edit this file, and save to a .ovpn extension
# so that OpenVPN will activate it when run
# as a service.
client
# Change 'myremote' to be your remote host,
# or comment out to enter a listening
# server mode..
remote grupoifm.no-ip.info
# Uncomment this line to use a different
# port number than the default of 1194.
; port 1194
# Choose one of three protocols supported by
# OpenVPN. If left commented out, defaults
# to udp.
; proto [tcp-server | tcp-client | udp]
# You must specify one of two possible network
# protocols, 'dev tap' or 'dev tun' to be used
# on both sides of the connection. 'tap' creates
# a VPN using the ethernet protocol while 'tun'
# uses the IP protocol. You must use 'tap'
# if you are ethernet bridging or want to route
# broadcasts. 'tun' is somewhat more efficient
# but requires configuration of client software
# to not depend on broadcasts. Some platforms
# such as Solaris, OpenBSD, and Mac OS X only
# support 'tun' interfaces, so if you are
# connecting to such a platform, you must also
# use a 'tun' interface on the Windows side.
# Enable 'dev tap' or 'dev tun' but not both!
dev tun
# This is a 'dev tap' ifconfig that creates
# a virtual ethernet subnet.
# 10.3.0.1 is the local VPN IP address
# and 255.255.255.0 is the VPN subnet.
# Only define this option for 'dev tap'.
#ifconfig 10.3.0.1 255.255.255.0
#ifconfig 10.3.0.1 255.255.255.0
# This is a 'dev tun' ifconfig that creates
# a point-to-point IP link.
# 10.3.0.1 is the local VPN IP address and
# 10.3.0.2 is the remote VPN IP address.
# Only define this option for 'dev tun'.
# Make sure to include the "tun-mtu" option
# on the remote machine, but swap the order
# of the ifconfig addresses.
;tun-mtu 1500
;ifconfig 10.3.0.1 10.3.0.2 10.3.0.5
# If you have fragmentation issues or misconfigured
# routers in the path which block Path MTU discovery,
# lower the TCP MSS and internally fragment non-TCP
# protocols.
;fragment 1300
;mssfix
# If you have set up more than one TAP-Win32 adapter
# on your system, you must refer to it by name.
;dev-node my-tap
# You can generate a static OpenVPN key
# by selecting the Generate Key option
# in the start menu.
#
# You can also generate key.txt manually
# with the following command:
# openvpn --genkey --secret key.txt
#
# key must match on both ends of the connection,
# so you should generate it on one machine and
# copy it to the other over a secure medium.
# Place key.txt in the same directory as this
# config file.
;secret key.txt
# Uncomment this section for a more reliable
# detection when a system loses its connection.
# For example, dial-ups or laptops that travel
# to other locations.
#
# If this section is enabled and "myremote"
# above is a dynamic DNS name (i.e. dyndns.org),
# OpenVPN will dynamically "follow" the IP
# address of "myremote" if it changes.
; ping-restart 60
; ping-timer-rem
; persist-tun
; persist-key
; resolv-retry 86400
# keep-alive ping
ping 10
# enable LZO compression
comp-lzo
# moderate verbosity
verb 7
mute 10
tls-client
dh dh1024.pem
ca ca.crt
cert filipi.crt
key filipi.key
Para se conectar execute o comando:
openvpn --config vpn.ovpn
Pronto, conectou !!!!
Assinar:
Postagens (Atom)