# Problem in gif-tunnel creation



## regular (Mar 6, 2014)

Hallo all. I have to create vpn through 2 FreeBSD 10.0 gateways. With command line I do it successfully. But I cannot do it with rc.conf.

When I write in rc.conf 

```
cloned_interfaces="gif0"
ifconfig_gif0="tunnel EXTIP1 EXTIP2"
ifconfig_gif0="inet 192.168.51.1 192.168.111.2 netmask 0xffffffff"
```
i receive 

```
gif0: flags=8011<UP,POINTOPOINT,MULTICAST> metric 0 mtu 1280
	inet 192.168.51.1 --> 192.168.111.2 netmask 0xffffffff 
	inet6 fe80::76d4:35ff:fe13:3863%gif0 prefixlen 64 tentative scopeid 0x7 
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
```


When I write in rc.conf (change line order)

```
cloned_interfaces="gif0"
ifconfig_gif0="inet 192.168.51.1 192.168.111.2 netmask 0xffffffff"
ifconfig_gif0="tunnel  EXTIP1 EXTIP2"
```
I receive 

```
gif0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1280
	tunnel inet EXTIP1 --> EXTIP2
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
```

What am I doing wrong?


----------



## kpa (Mar 6, 2014)

The rc.conf file is a shell script and it uses the /bin/sh shell's variable assignment conventions. What you're now doing is first assigning one value to ifconfig_gif0 and immediately after it overriding the value with another one. Combine the two lines into one:


```
ifconfig_gif0="tunnel EXTIP1 EXTIP2 inet 192.168.51.1 192.168.111.2 netmask 0xffffffff"
```


----------



## regular (Mar 6, 2014)

kpa said:
			
		

> The rc.conf file is a shell script and it uses the /bin/sh shell's variable assignment conventions. What you're now doing is first assigning one value to ifconfig_gif0 and immediately after it overriding the value with another one. Combine the two lines into one:
> 
> 
> ```
> ...


In this case I receive

```
gif0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1280
   tunnel inet EXTIP1 --> EXTIP2
   nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
```
but  I change order parameters

```
ifconfig_gif0="inet 192.168.51.1 192.168.111.2 netmask 0xffffffff tunnel EXTIP1 EXTIP2"
```
and receive

```
gif0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1280
	tunnel inetEXTIP1 --> EXTIP2
	inet 192.168.51.1 --> 192.168.111.2 netmask 0xffffffff
```
Thank you for your help!


----------



## kpa (Mar 6, 2014)

Oh yea, the order seems to be important. What's in the variable is fed straight to ifconfig(8) that seems to be quite picky about the order.


----------

