tun
(para túneis IP-level) e tap
(para túneis Ethernet-level) são suportadas. Na pratica, a interface tun
irá geralmente ser a mais usada, excerto quando os clientes VPN forem feitos para serem integrados na rede local do servidor por meio de uma ponte (brigde) Ethernet.
openssl
.
$
make-cadir pki-falcot
$
cd pki-falcot
vars
, especialmente aqueles nomeados com o prefixo KEY_
; essas variáveis são então integradas ao ambiente:
$
vim vars
$
grep KEY_ vars
export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA` export KEY_DIR="$EASY_RSA/keys" echo NOTE: If you run ./clean-all, I will be doing a rm -rf on $KEY_DIR export KEY_SIZE=2048 export KEY_EXPIRE=3650 export KEY_COUNTRY="FR" export KEY_PROVINCE="Loire" export KEY_CITY="Saint-Étienne" export KEY_ORG="Falcot Corp" export KEY_EMAIL="admin@falcot.com" export KEY_OU="Certificate authority" export KEY_NAME="Certificate authority for Falcot Corp" # If you'd like to sign all keys with the same Common Name, uncomment the KEY_CN export below # export KEY_CN="CommonName" $
. ./vars
NOTE: If you run ./clean-all, I will be doing a rm -rf on /home/roland/pki-falcot/keys $
./clean-all
keys/ca.crt
e keys/ca.key
durante esse passo):
$
./build-ca
Generating a 2048 bit RSA private key ...................................................................+++ ...+++ writing new private key to 'ca.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [FR]: State or Province Name (full name) [Loire]: Locality Name (eg, city) [Saint-Étienne]: Organization Name (eg, company) [Falcot Corp]: Organizational Unit Name (eg, section) [Certificate authority]: Common Name (eg, your name or your server's hostname) [Falcot Corp CA]: Name [Certificate authority for Falcot Corp]: Email Address [admin@falcot.com]:
vpn.falcot.com
; esse nome é reutilizado nos arquivos de chave gerados (keys/vpn.falcot.com.crt
para certificado público, keys/vpn.falcot.com.key
para chave privada):
$
./build-key-server vpn.falcot.com
Generating a 2048 bit RSA private key .....................................................................................................................+++ ...........+++ writing new private key to 'vpn.falcot.com.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [FR]: State or Province Name (full name) [Loire]: Locality Name (eg, city) [Saint-Étienne]: Organization Name (eg, company) [Falcot Corp]: Organizational Unit Name (eg, section) [Certificate authority]: Common Name (eg, your name or your server's hostname) [vpn.falcot.com]: Name [Certificate authority for Falcot Corp]: Email Address [admin@falcot.com]: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Using configuration from /home/roland/pki-falcot/openssl-1.0.0.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows countryName :PRINTABLE:'FR' stateOrProvinceName :PRINTABLE:'Loire' localityName :T61STRING:'Saint-\0xFFFFFFC3\0xFFFFFF89tienne' organizationName :PRINTABLE:'Falcot Corp' organizationalUnitName:PRINTABLE:'Certificate authority' commonName :PRINTABLE:'vpn.falcot.com' name :PRINTABLE:'Certificate authority for Falcot Corp' emailAddress :IA5STRING:'admin@falcot.com' Certificate is to be certified until Mar 6 14:54:56 2025 GMT (3650 days) Sign the certificate? [y/n]:
y
1 out of 1 certificate requests certified, commit? [y/n]
y
Write out database with 1 new entries Data Base Updated $
./build-dh
Generating DH parameters, 2048 bit long safe prime, generator 2 This is going to take a long time […]
$
./build-key JoeSmith
Generating a 2048 bit RSA private key ................................+++ ..............................................+++ writing new private key to 'JoeSmith.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [FR]: State or Province Name (full name) [Loire]: Locality Name (eg, city) [Saint-Étienne]: Organization Name (eg, company) [Falcot Corp]: Organizational Unit Name (eg, section) [Certificate authority]:
Development unit
Common Name (eg, your name or your server's hostname) [JoeSmith]:
Joe Smith
[…]
keys/ca.crt
) será armazenada em todas as máquinas (tanto servidor quanto clientes) como /etc/ssl/certs/Falcot_CA.crt
. O certificado do servidor é instalado apenas no servidor (keys/vpn.falcot.com.crt
vai para /etc/ssl/vpn.falcot.com.crt
, e keys/vpn.falcot.com.key
vai para /etc/ssl/private/vpn.falcot.com.key
com restritivas permissões para que apenas o administrador possa lê-la), com os parâmetros Diffie-Hellman correspondentes (keys/dh2048.pem
) instalados em /etc/openvpn/dh2048.pem
. Certificados do clientes são instalados no cliente VPN correspondente de maneira similar.
/etc/openvpn/*.conf
. A configuração de um servidor VPN é portanto uma questão de armazenar o arquivo de configuração correspondente neste diretório. Um bom ponto de partida é o /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz
, que orienta em como ter um servidor padrão. Claro que alguns parâmetros precisam ser adaptados: ca
, cert
, key
e dh
precisam descrever as localizações selecionadas (respectivamente, /etc/ssl/certs/Falcot_CA.crt
, /etc/ssl/vpn.falcot.com.crt
, /etc/ssl/private/vpn.falcot.com.key
e /etc/openvpn/dh2048.pem
). A diretiva server 10.8.0.0 255.255.255.0
define a sub-rede a ser usada pela VPN; o servidor usa o primeiro endereço IP nesse intervalo (10.8.0.1
) e o resto dos endereços são alocados para os clientes.
tun0
. Contudo, firewalls são geralmente configurados ao mesmo tempo que interfaces de rede reais, o que acontece antes do OpenVPN ser iniciado. A boa prática então recomenda a criação de uma interface de rede virtual persistênte, e configurara o OpenVPN a usar essa pré-existente interface. Isso inclusive permite a escolha do nome dessa interface. Para esse fim, openvpn --mktun --dev vpn --dev-type tun
cria uma interface de rede virtual de nome vpn
do tipo tun
; esse comando pode ser facilmente integrado ao script de configuração do firewall, ou na diretiva up
do arquivo /etc/network/interfaces
. O arquivo de configuração do OpenVPN deve também ser atualizado em conformidade com as diretivas dev vpn
e dev-type tun
.
10.8.0.1
. Permitir que os clientes acessem a rede local (192.168.0.0/24) requer a adição da diretiva push route 192.168.0.0 255.255.255.0
na configuração do OpenVPN para que os clientes VPN automaticamente recebam o roteamento dizendo a eles que essa rede é alcançável através da VPN. Além do mais, máquinas na rede local também precisam ser informadas que a rota para a VPN passa pelo servidor VPN (isso funciona de maneira automática quando o servidor VPN é instalado no gateway). Alternativamente, o servidor VPN pode ser configurado para desempenhar um mascaramento IP, e assim as conexões vidas de clientes VPN aparecem com se elas viessem do servidor VPN (see Seção 10.1, “Gateway”).
/etc/openvpn/
. Uma configuração padrão pode ser obtida usando /usr/share/doc/openvpn/examples/sample-config-files/client.conf
como ponto de partida. A diretiva remote vpn.falcot.com 1194
descreve o endereço e porta do servidor OpenVPN; ca
, cert
and key
também precisam ser adaptadas para descrever a localização dos arquivos com as chaves.
AUTOSTART
para none
no arquivo /etc/default/openvpn
. Iniciar ou parar uma determinada conexão VPN é sempre possível com os comandos service openvpn@name start
and service openvpn@name stop
(aonde a conexão nome casa com uma definida em /etc/openvpn/nome.conf
).
tun*
) on both sides of an SSH connection, and these virtual interfaces can be configured exactly as if they were physical interfaces. The tunneling system must first be enabled by setting PermitTunnel
to “yes” in the SSH server configuration file (/etc/ssh/sshd_config
). When establishing the SSH connection, the creation of a tunnel must be explicitly requested with the -w any:any
option (any
can be replaced with the desired tun
device number). This requires the user to have administrator privilege on both sides, so as to be able to create the network device (in other words, the connection must be established as root).
/etc/ipsec-tools.conf
de cada máquina contém os parâmetros para os túneis IPsec (ou Security Associations, na terminologia IPsec) que o hospedeiro se preocupa; o script /etc/init.d/setkey
fornece uma maneira para iniciar e parar um túnel (cada túnel é uma ligação segura para outra máquina conectada a rede virtual privada). Esse arquivo pode ser construído manualmente a partir da documentação fornecida pela página de manual setkey(8). Contudo, escrever explicitamente os parâmetros para todas as máquinas em um conjunto não-trivial de máquinas rapidamente se torna uma tarefa árdua, já que o número de túneis cresce rápido. Instalar um daemon IKE (para IPsec Key Exchange) como o racoon ou strongswan torna o processo muito mais simples, por reunir a administração em um ponto central, e mais seguro por rotacionar as chaves periodicamente.
/etc/ppp/options.pptp
, /etc/ppp/peers/falcot
, /etc/ppp/ip-up.d/falcot
, e /etc/ppp/ip-down.d/falcot
.
Exemplo 10.2. O arquivo /etc/ppp/options.pptp
# PPP options used for a PPTP connection lock noauth nobsdcomp nodeflate
Exemplo 10.3. O arquivo /etc/ppp/peers/falcot
# vpn.falcot.com is the PPTP server pty "pptp vpn.falcot.com --nolaunchpppd" # the connection will identify as the "vpn" user user vpn remotename pptp # encryption is needed require-mppe-128 file /etc/ppp/options.pptp ipparam falcot
pptpd
é o servidor PPTP para Linux. Seu principal arquivo de configuração, /etc/pptpd.conf
, requer muito poucas alterações: localip (endereço IP local) e remoteip (endereço IP remoto). No exemplo abaixo, o servidor PPTP sempre usa o endereço 192.168.0.199
, e os clientes PPTP recebem endereços IP entre 192.168.0.200
e 192.168.0.250
.
Exemplo 10.6. O arquivo /etc/pptpd.conf
# TAG: speed # # Specifies the speed for the PPP daemon to talk at. # speed 115200 # TAG: option # # Specifies the location of the PPP options file. # By default PPP looks in '/etc/ppp/options' # option /etc/ppp/pptpd-options # TAG: debug # # Turns on (more) debugging to syslog # # debug # TAG: localip # TAG: remoteip # # Specifies the local and remote IP address ranges. # # You can specify single IP addresses separated by commas or you can # specify ranges, or both. For example: # # 192.168.0.234,192.168.0.245-249,192.168.0.254 # # IMPORTANT RESTRICTIONS: # # 1. No spaces are permitted between commas or within addresses. # # 2. If you give more IP addresses than MAX_CONNECTIONS, it will # start at the beginning of the list and go until it gets # MAX_CONNECTIONS IPs. Others will be ignored. # # 3. No shortcuts in ranges! ie. 234-8 does not mean 234 to 238, # you must type 234-238 if you mean this. # # 4. If you give a single localIP, that's ok - all local IPs will # be set to the given one. You MUST still give at least one remote # IP for each simultaneous client. # #localip 192.168.0.234-238,192.168.0.245 #remoteip 192.168.1.234-238,192.168.1.245 #localip 10.0.1.1 #remoteip 10.0.1.2-100 localip 192.168.0.199 remoteip 192.168.0.200-250
/etc/ppp/pptpd-options
. Os parâmetros importantes são o nome do servidor (pptp
), o nome de domínio (falcot.com
), e o endereço IP para os servidores DNS e WINS.
Exemplo 10.7. O arquivo /etc/ppp/pptpd-options
## turn pppd syslog debugging on #debug ## change 'servername' to whatever you specify as your server name in chap-secrets name pptp ## change the domainname to your local domain domain falcot.com ## these are reasonable defaults for WinXXXX clients ## for the security related settings # The Debian pppd package now supports both MSCHAP and MPPE, so enable them # here. Please note that the kernel support for MPPE must also be present! auth require-chap require-mschap require-mschap-v2 require-mppe-128 ## Fill in your addresses ms-dns 192.168.0.1 ms-wins 192.168.0.1 ## Fill in your netmask netmask 255.255.255.0 ## some defaults nodefaultroute proxyarp lock
vpn
user (and the associated password) in the /etc/ppp/chap-secrets
file. Contrary to other instances where an asterisk (*
) would work, the server name must be filled explicitly here. Furthermore, Windows PPTP clients identify themselves under the DOMAIN\\USER
form, instead of only providing a user name. This explains why the file also mentions the FALCOT\\vpn
user. It is also possible to specify individual IP addresses for users; an asterisk in this field specifies that dynamic addressing should be used.