From: wizztick Date: Sat, 18 Feb 2012 11:12:17 +0000 (+0100) Subject: (no commit message) X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=3bb6801754bb5b9e150a22508e7b4b735f022502;p=wiki --- diff --git a/examples/macbook-install.mdwn b/examples/macbook-install.mdwn index b7d7a0f..a45a989 100644 --- a/examples/macbook-install.mdwn +++ b/examples/macbook-install.mdwn @@ -10,6 +10,82 @@ This page explains how to intergrate tinc as a system service on a laptop. Allow ### Configuration of tinc for a laptop +The configuration as used on the [[osx-install]] page works on a laptop. The important thing is that the host-file descrbing the laptop does not give an ip address, because it changes to wherever the laptop will be. Instead, the laptop sould have a ConnectTo = myserver line in its tincd.conf file. + +Auto discovery (bonjour) of network services on the vpn might work when tinc runs in Router mode. But I use a switch-based network to make the laptop appear as part of my local network, which even allows dhcp to work over the vpn. Note that this can lower the performance of your vpn. To use the switch mode in tinc, just add the line 'Mode = Switch' in the tincd.conf on the server and laptop side. If you have a local network, you will also need a bridge on the server between your local network and the vpn. There are guides on how to setup such a bridge but I give an example below. + + +#### Setup a bridge on your server + +We assume *eth0* is your local network. We name the brigde *priv*, but you can use any name. On your server bring down eth0 using *ifdown eth0*. **Be careful not to shut yourself out**. In /etc/network/interfaces add: + + # Prevent NetworkManager to run on these interfaces + iface eth0 inet manual + + # Start priv on boot + auto priv + # make eth0 part of the bridge priv and configure priv via dhcp + iface priv inet dhcp + bridge_ports eth0 + +If there are other references to eth0, these should likely be removed. Now the tinc-up file of your vpn on your server should look like: + + #!/bin/sh + ifconfig "$INTERFACE" up + brctl addif priv "$INTERFACE" + +The tinc-down file should be: + + #!/bin/sh + brctl delif priv "$INTERFACE" + +This add and removes the vpn interface as part of the bridge if tinc starts or stops. A bridge is like a virtual switch and allows two network devices to be on the same subnet. + ### Start tinc at startup +OS X has something called [launchd](http://en.wikipedia.org/wiki/Launchd). This is a system for monitoring services and make sure services are started if certain conditions are met. This is used at least on OS X 10.5 and maybe newer versions as well. (If you want me to check it, you have to give me a laptop with that version installed on it.) + +To use launchd, you have to create a property-list file for tinc and put it under /Library/LaunchDaemons/ + +For instance, I created */Library/LaunchDaemons/myvpn.tinc.plist* with the following: + + + + + + KeepAlive + + Label + tinc.myvpn + ProgramArguments + + /usr/local/tinc/sbin/tincd + -n + myvpn + -D + + + + +This will configures tincd to start the myvpn configuration in the foreground (-D). If tincd is started as background daemon, launchd will become confused. Launchd will directly start tincd if this file is found (it might be that you first have to use the load command as explained below - I cannot remember), the KeepAlive will ensure that if tincd will stop, it is restarted directly. To be able to stop tincd you have to use *launchctl*. Good commands to remember are: + + launchctl unload -w /Library/LaunchDaemons/myvpn.tinc.plist + +This adds a *disabled* key to the file and stops tincd. The disabled key ensure that launchd will not start tincd anymore. The inverse operation is: + + launchctl load -w /Library/LaunchDaemons/myvpn.tinc.plist + +This removes the *disabled* key from the file and starts tincd. Using: + + launchctl list + +you will get a list of all services monitored by launchd. If done correctly, you will see tinc.myvpn listed with some process id. + +There is also a stop command: + + launchctl stop tinc.myvpn + +But because the property list does not specify any condition when to start the command, launchd will directly start the tinc.myvpn service again. + ### Reconnect tinc if internet becomes available +