Próxima revisión | Revisión previa |
es:howtos:network_services:tunnel_interfaces [2019/02/11 12:25 (UTC)] – creado slackwarespanol | es:howtos:network_services:tunnel_interfaces [2019/02/14 18:49 (UTC)] (actual) – [Sources] slackwarespanol |
---|
====== Tunnel Interfaces ====== | ====== Interfaces de túnel ====== |
If you are looking to establish an SSH tunnel between two networks and treat the tunnel as an interface, this may help. | Si está buscando establecer un túnel SSH entre dos redes y tratar el túnel como una interfaz, esto puede ayudar. |
| |
* First I would recommend enabling rc.ip_forward in /etc/rc.d/ (on local and target machines) <code bash> | * Primero recomendaría habilitar rc.ip_forward en /etc/rc.d/ (en máquinas locales y de destino)<code bash> |
root@darkstar:~# chmod +x /etc/rc.d/rc.ip_forward | root@darkstar:~# chmod +x /etc/rc.d/rc.ip_forward |
</code> or for a temporary (lose at reboot) way use <code bash> | </code> o para un uso temporal (se pierde al reiniciar) <code bash> |
root@darkstar:~# echo "1" > /proc/sys/net/ipv4/ip_forward | root@darkstar:~# echo "1" > /proc/sys/net/ipv4/ip_forward |
</code> | </code> |
* Almost forgot you will need to enable tunneling in /etc/ssh/sshd_conf. Find this part //#PermitTunnel no// uncomment and change to yes (on the target machine) you can use vi to edit or try the below code:<code bash> | * Casi se me olvida que tendrá que habilitar el túnel en /etc/ssh/sshd_conf. Encuentre esta parte // # PermitTunnel no // descomentar y cambie a sí (en la máquina de destino) puede usar vi para editar o probar el siguiente código:<code bash> |
root@darkstar:~# /usr/bin/sudo /bin/sed -e "s/#PermitTunnel\ no/PermitTunnel\ yes\ #changed\ `date '+%Y%m%d' \ | root@darkstar:~# /usr/bin/sudo /bin/sed -e "s/#PermitTunnel\ no/PermitTunnel\ yes\ #changed\ `date '+%Y%m%d' \ |
`\ by\ `/bin/whoami`/" -i.stock_slackware-`/bin/awk '{print $2}' /etc/slackware-version` /etc/ssh/sshd_config</code> | `\ by\ `/bin/whoami`/" -i.stock_slackware-`/bin/awk '{print $2}' /etc/slackware-version` /etc/ssh/sshd_config</code> |
* Next I'm using autossh found at [[http://slackbuilds.org/result/?search=autossh|slackbuilds.org]] . The below script requires it (there is an alternate method mentioned at the bottom. Replace line 20.) | * A continuación, estoy usando autossh que se encuentra en [[http://slackbuilds.org/result/?search=autossh|slackbuilds.org]]. El siguiente script lo requiere (hay un método alternativo mencionado en la parte inferior. Reemplace la línea 20). |
* You will also want to have non-interactive ssh connections set up. Meaning [[howtos:security:sshkeys|authorized_keys setup with public/private keys]]. | * También querrá tener configuradas conexiones ssh no interactivas.[[:es:howtos:security:sshkeys | Cómo utilizar las claves SSH para conectarse sin una contraseña.]]. |
* Also assuming you have sudo privileges and user on the remote machine (using the ''NOPASSWD: ALL'' option in ''/etc/sudoers'') \\ Example: as root type "''visudo''" and add your user like this <code bash> | * También asumiendo que tiene privilegios de sudo y usuario en la máquina remota (usando la opción '' NOPASSWD: ALL '' en '' /etc/sudoers '') \\ Ejemplo: como tipo de raíz "'' visudo ''" y agregue a tu usuario le gusta esto <code bash> |
rich ALL=(ALL) NOPASSWD: ALL | rich ALL=(ALL) NOPASSWD: ALL |
</code> | </code> |
* Next I'm using a simple bash script which I will explain after peeking at it. <file bash rc.tunnel> | * A continuación estoy usando un simple script de bash que explicaré después de echarle un vistazo. <file bash rc.tunnel> |
#!/bin/bash | #!/bin/bash |
| |
</file> | </file> |
| |
* To direct traffic over the tunnel try: <code bash> | * Para dirigir el tráfico sobre el túnel intente: <code bash> |
user@darkstar:~$ sudo /sbin/route add -net 74.125.131.0 netmask 255.255.255.0 dev tun0 | user@darkstar:~$ sudo /sbin/route add -net 74.125.131.0 netmask 255.255.255.0 dev tun0 |
</code> | </code> |
| |
* To substitute normal ssh rather than autossh substitute this line below for the one with autossh (line 20)<code bash> | * Para sustituir ssh normal en lugar de autossh, sustituya esta línea a continuación por una con autossh (línea 20)<code bash> |
/usr/bin/sudo /usr/bin/ssh -p $port -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -fw 0:0 $target /bin/true | /usr/bin/sudo /usr/bin/ssh -p $port -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -fw 0:0 $target /bin/true |
</code> | </code> |
| |
To recap some of the options: "''-fw 0:0''" forks the ssh process to the background / opens a tunnel and "''0:0''" picks the local and remote interfaces (ie tun0 and tun0). The "''-o''" options are used to specify parameters for openSSH. | Para recapitular algunas de las opciones: "'' -fw 0: 0 ''" coloca el proceso ssh en segundo plano/abre un túnel y "'' 0: 0 ''" selecciona las interfaces locales y remotas (es decir, tun0 y tun0 ). Las opciones "'' -o ''" se utilizan para especificar parámetros para openSSH. |
| |
==== Results ==== | ==== Resultados ==== |
| |
Now you can access the remote computer using "''192.168.5.2''" and your communications will go through the ssh tunnel. In the above script you may wish to modify the network and mask to fit your needs. I chose "''192.168.5''" but your configuration will likely be different. | Ahora puede acceder a la computadora remota usando "'' 192.168.5.2 ''" y sus comunicaciones pasarán por el túnel ssh. En el script anterior, es posible que desee modificar la red y la máscara para que se ajusten a sus necesidades. Elegí "'' 192.168.5 ''" pero su configuración probablemente será diferente. |
| |
I'm not going to be able to elaborate on the iptables rules still a little green there, but they work. | No podré elaborar las reglas de iptables todavía un poco verdes allí, pero funcionan. |
| ====== Fuentes ====== |
====== Sources ====== | |
<!-- If you are copying information from another source, then specify that source --> | <!-- If you are copying information from another source, then specify that source --> |
<!-- * Original source: [[http://some.website.org/some/page.html]] --> | <!-- * Original source: [[http://some.website.org/some/page.html]] --> |
<!-- Authors are allowed to give credit to themselves! --> | <!-- Authors are allowed to give credit to themselves! --> |
* Originally written by [[wiki:user:ricky_cardo | ricky_cardo]] | * Escrito originalmente por [[wiki:user:ricky_cardo | ricky_cardo]] |
| * Traducido por: [[wiki:user: slackwarespanol | Victor]] 2019/02/14 18:47 (UTC) |
<!-- * Contributions by [[wiki:user:yyy | User Y]] --> | <!-- * Contributions by [[wiki:user:yyy | User Y]] --> |
| |
<!-- Please do not modify anything below, except adding new tags.--> | <!-- Please do not modify anything below, except adding new tags.--> |
{{tag>howtos tunnel tun0 author_ricky_cardo}} | {{tag>howtos tunnel tun0 author_ricky_cardo}} |