1 |
On Wednesday 21 Mar 2012 02:05:03 Michael J. Hill wrote: |
2 |
> Hello, |
3 |
> |
4 |
> In testing, I have gotten this setup to work by manually completing the |
5 |
> necessary steps; however, I am now looking to have everything completed |
6 |
> automatically so as to ensure my setup persists over a reboot. |
7 |
> |
8 |
> Firstly, an outline of what I am doing: |
9 |
> * I have a Gentoo VM running at home, functioning as my firewall/router, |
10 |
> which works perfectly fine. * Said VM has established an IPSEC tunnel to a |
11 |
> dedicated server using OpenSWAN. This also works perfectly fine. * A tun0 |
12 |
> interface is created on both devices, setting up an IPIP PPP tunnel that |
13 |
> sits on top of the IPSEC tunnel. * Firewall and Routing rules are in place |
14 |
> to perform policy-based routing over this tun0 interface. This again, |
15 |
> works perfectly fine. |
16 |
> |
17 |
> For the rest, the following configuration is worth noting: |
18 |
> * The dedicated server is running CentOS 6, not that this is of necessary |
19 |
> import for this configuration. * 172.18.0.1 resides on the dedicated |
20 |
> server. |
21 |
> * 10.0.0.1 is the management IP of my Gentoo VM, and serves as its identity |
22 |
> as well. * 172.18.1.0/24 is the network utilized for the tunnel, with |
23 |
> 172.18.1.1 on the dedicated server, and 172.18.1.2 on the Gentoo VM. |
24 |
> |
25 |
> In effect, the first thing I need to do, is automate the IPIP PPP tunnel |
26 |
> setup so that the device can persist over a reboot. I can create it |
27 |
> manually right now, no problem, with the following command strings: # ip |
28 |
> tunnel add tun0 mode ipip remote 172.18.0.1 local 10.0.0.1 |
29 |
> # ip addr add 172.18.1.2/24 dev tun0 |
30 |
> # ip link set tun0 mtu 1500 |
31 |
> # i p link set tun0 up |
32 |
> |
33 |
> This all works perfectly fine, and tun0 is created after running the first |
34 |
> command. Now I need this to persist a reboot. I wanted to handle this |
35 |
> through OpenRC, since I can then do dependency resolution, and make sure |
36 |
> the tunnel comes up only if the IPSEC tunnel is up and running. That being |
37 |
> said, I added the following to /etc/conf.d/net: |
38 |
|
39 |
Shouldn't you create the ipip tunnel here first? |
40 |
|
41 |
Something like: |
42 |
|
43 |
iptunnel_tun0="mode ipip remote 172.18.0.1 ttl 255" #not sure if local is |
44 |
required, you can try with & without. |
45 |
|
46 |
|
47 |
> link_tun0="ipsec0" #Not sure this is correct, shouldn't it be an iface? |
48 |
|
49 |
> config_tun0="172.18.1.2 netmask 255.255.255.0 brd 172.18.1.255" |
50 |
> dns_servers_tun0="10.0.1.2" |
51 |
> routes_tun0=( |
52 |
> "64.20.39.38/32 via 172.18.1.1" |
53 |
> "default via 172.18.1.1 table ipsec" |
54 |
> ) |
55 |
> mtu_tun0="1500" |
56 |
> iptunnel_tun0_remote="172.18.0.1" |
57 |
> iptunnel_tun0_local="10.0.0.1" |
58 |
> iptunnel_tun0_mode="ipip remote ${iptunnel_tun0_remote} local |
59 |
> ${iptunnel_tun0_local} dev ${link_tun0}" rc_net_tun0_need="ipsec" |
60 |
> preup() { |
61 |
> # If the link does not exist, return now, it's a tunnel! |
62 |
> ip link show dev ${IFACE} 2>/dev/null || return 0 |
63 |
> } |
64 |
> |
65 |
> Now, the configuration does reflect an additional item not in my original |
66 |
> setup, which links tun0 to the ipsec0 interface. I've tested with and |
67 |
> without this, and it doesn't work. Attempting to bring up the interface |
68 |
> using rc-service results in the following error: Cannot find device "tun0" |
69 |
> * ERROR: interface tun0 does not exist |
70 |
> * Ensure that you have loaded the correct kernel module for your hardware |
71 |
> * ERROR: net.tun0 failed to start |
72 |
> |
73 |
> I could easily script all this out, and probably call it through rc.local, |
74 |
> but I'd rather be able to utilize the dependency resolution to make sure |
75 |
> all the necessary components are up. |
76 |
> |
77 |
> Any insights on getting it to behave? |
78 |
> |
79 |
> Michael Hill |
80 |
|
81 |
-- |
82 |
Regards, |
83 |
Mick |