Question: Is it possible to create an VPN connection while using site-to-site VPN?

Have you ever tried or done this?

What are possible problems, pitfalls, things of the impossible, etc. ?

Also see: [Is it possible to use Microsoft's "Secure Connection Rules" (IPSec) with VPN?](https://serverfault.com/questions/126537/is-it-possible-to-use-microsofts-secure-connection-rules-ipsec-with-vpn)

Answer: 
Here's a complete solution. Keep a list of your servers ip addresses and/or domains and the colors you want for them in in ~/.server\_colors:

```

192.168.122.102,Red Sands
192.168.122.103,Ocean
www.foo.com,Grass
foo.com,Grass

```

Then add this line to ~/.profile to hijack the ssh command:

```
alias ssh="~/bin/safe_ssh $1"
```

Then compare whatever's after the @ in your ssh target to your list. If there's a match, run an AppleScript to change the screen to the corresponding color. Here's ~/bin/safe\_ssh:

```

#!/bin/bash
ip=`echo $1 | cut -d"@" -f2`
match=`cat ~/.server_colors | grep $ip | wc -l`
if [ $match -gt 0 ]
then
    color=`cat ~/.server_colors | grep $ip | cut -f2 -d","`
    osascript ~/bin/change_terminal_color.scpt "$color" 2>/dev/null
fi
/usr/bin/ssh $1

```

And last, here's ~/bin/change\_terminal\_color.scpt

```

on run argv
    tell application "Terminal" to set current settings of selected tab of window 1 to (first settings set whose name is (item 1 of argv))
end run

```

I took most of this code from [this blog post](http://www.sipfish.com/blog/automatically-change-command-line-colors-when-using-ssh/).
If you are using iTerm2, create a file named `~/bin/ssh-host-color.sh` with the contents from <https://gist.github.com/jbochi/31f118b8ae2882a2c90fa46c46509b57>:

```
set_term_bgcolor(){
  local R=$1
  local G=$2
  local B=$3
  /usr/bin/osascript <<EOF
tell application "iTerm"
  tell the current window
    tell the current session
      set background color to {$(($R*65535/255)), $(($G*65535/255)), $(($B*65535/255))}
    end tell
  end tell
end tell
EOF
}

if [[ "$@" =~ "production.example.com" ]]; then
  set_term_bgcolor 40 0 0
elif [[ "$@" =~ "qa.example.com" ]]; then
  set_term_bgcolor 0 40 0
fi

trap "set_term_bgcolor 0 0 0" EXIT

ssh $@

```

And add the following line to your `~/.aliases.sh` file:

```
alias ssh="~/bin/ssh-host-color.sh $@"

```