[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
howtos:network_services:tunnel_interfaces [2013/02/13 02:00 (UTC)] – [Sources] ricky_cardo | howtos:network_services:tunnel_interfaces [2020/06/25 13:41 (UTC)] (current) – [Results] ricky_cardo | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). --> | ||
====== Tunnel Interfaces ====== | ====== Tunnel Interfaces ====== | ||
If you are looking to establish an SSH tunnel between two networks and treat the tunnel as an interface, this may help. | If you are looking to establish an SSH tunnel between two networks and treat the tunnel as an interface, this may help. | ||
- | * First I would recommend enabling rc.ip_forward in /etc/rc.d/ (on local and target machines) | + | * First I would recommend enabling rc.ip_forward in /etc/rc.d/ (on local and target machines) <code bash> |
- | <note tip>chmod +x / | + | root@darkstar: |
- | or for a temporary (loose at reboot) way use | + | </code> or for a temporary (lose at reboot) way use <code bash> |
- | <note tip>echo " | + | root@darkstar: |
- | + | </code> | |
- | * Next I'm using autossh found at slackbuilds.org The below script requires it. (there is likely a way without it since it is a wrapper... | + | * Almost forgot you will need to enable tunneling in / |
- | * You will also want to have non-interactive ssh connections set up. Meaning authorized_keys setup with public/ | + | root@darkstar: |
- | * Also assuming you have sudo privledges | + | `\ by\ `/ |
- | <note tip>rich ALL=(ALL) NOPASSWD: ALL</note> | + | * Next I'm using autossh found at [[http://slackbuilds.org/ |
- | * Next I'm using a little | + | * You will also want to have non-interactive ssh connections set up. Meaning |
- | <file bash rc.tunnel># | + | * Also assuming you have sudo privileges |
+ | rich ALL=(ALL) NOPASSWD: ALL | ||
+ | </code> | ||
+ | * Next I'm using a simple | ||
+ | #!/bin/bash | ||
########################################################### | ########################################################### | ||
Line 21: | Line 24: | ||
# | # | ||
target=74.79.121.210 | target=74.79.121.210 | ||
+ | port=22 | ||
# | # | ||
########################################################### | ########################################################### | ||
- | # suggestions contact rich at lehcar.no-ip.org | + | # suggestions contact rich at lehcar.duckdns.org |
# with thanks to Billy T (for idea and assistance) | # with thanks to Billy T (for idea and assistance) | ||
########################################################### | ########################################################### | ||
Line 29: | Line 33: | ||
/ | / | ||
#load remote module | #load remote module | ||
- | / | + | / |
/bin/sleep 1 | /bin/sleep 1 | ||
- | / | + | / |
/bin/sleep 4 | /bin/sleep 4 | ||
- | / | + | / |
/ | / | ||
/ | / | ||
- | / | + | / |
/ | / | ||
- | / | + | / |
- | / | + | / |
- | / | + | / |
</ | </ | ||
- | To direct traffic over the tunnel try: | + | * To direct traffic over the tunnel try: <code bash> |
- | <note tip>sudo /sbin/route add -net 74.125.131.0 netmask 255.255.255.0 dev tun0</note> | + | user@darkstar: |
+ | </code> | ||
+ | |||
+ | * To substitute normal ssh rather than autossh substitute this line below for the one with autossh (line 20)<code bash> | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | To recap some of the options: | ||
+ | |||
+ | ==== Results ==== | ||
+ | |||
+ | Now you can access the remote computer using "'' | ||
- | To recap some options -fw 0:0 forks ssh process to the background / opens tunnel and 0:0 picks the interface local and remote. (ie tun0 and tun0) The -o options are to use options in openSSH. | ||
- | == Results == | ||
- | Now you can access the remote computer using 192.168.5.2 and your communications go over the ssh tunnel. | ||
I'm not going to be able to elaborate on the iptables rules still a little green there, but they work. | I'm not going to be able to elaborate on the iptables rules still a little green there, but they work. | ||
+ | **Here are a couple usage examples.** | ||
+ | Directing traffic to the tunnel interface. | ||
+ | <code bash>/ | ||
+ | /sbin/route add -net 10.10.182.15 netmask 255.255.255.255 dev tun0</ | ||
====== Sources ====== | ====== 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:// | <!-- * Original source: [[http:// | ||
<!-- Authors are allowed to give credit to themselves! --> | <!-- Authors are allowed to give credit to themselves! --> | ||
- | * Originally written by [[wiki: | + | |
<!-- * Contributions by [[wiki: | <!-- * Contributions by [[wiki: | ||
<!-- Please do not modify anything below, except adding new tags.--> | <!-- Please do not modify anything below, except adding new tags.--> | ||
- | <!-- You must remove the tag-word " | + | {{tag> |
- | {{tag> | + |