# gif(4) TCP/IPv6 routing after service netif restart



## grahamperrin@ (Feb 13, 2022)

I use the Hurricane Electric Free IPv6 Tunnel Broker service, most recently configured to work with my wired network at home.

gif(4), em(4).

Re: <https://forums.freebsd.org/posts/556270> I temporarily used Wi-Fi instead of a wired connection, to compare speeds. Then, wishing to revert to wired networking:

`service netif restart`

… and other things, including `ifconfig wlan0 down` (because `NOAUTO` is broken). I regained routing for TCP/IPv4 but not for TCP/IPv6:


```
% ping -6 freshports.org
ping: UDP connect: No route to host
%
```

What to do?

FreeBSD 14.0-CURRENT.


----------



## grahamperrin@ (Feb 13, 2022)

covacat said:


> verify gif is up and configured both outer and inner
> 
> `route -n add -inet6 default gif6endpoint`



Thanks, that worked, using the IPv6 tunnel server IPv6 address *minus* the `/64` tail:






I imagined that `service defaultroute restart` would have done what's required. 

Is it always necessary to discover the address, then manually add the default route, following `service netif restart`?


----------



## grahamperrin@ (Feb 13, 2022)

… I mean, what's required is in already my /etc/rc.conf so, can I run a simpler command to have the route added using what's in the file?


----------



## covacat (Feb 13, 2022)

looks like service defaultroute only does it for dhcp
service routing will do the static ones
add ipv6_defaultroute in rc.conf


----------



## grahamperrin@ (Feb 13, 2022)

Thanks,



covacat said:


> add ipv6_defaultroute in rc.conf



I already have the required value for this, with an `r`

`ipv6_defaultrouter`

– correct?


----------



## covacat (Feb 13, 2022)

yes


----------



## grahamperrin@ (Feb 13, 2022)

Thanks again. 

I find `service routing restart` not reliable, there's a related observation: 



> > /etc/rc.d/routing isn't a service. …



Thoughts?


----------



## grahamperrin@ (Feb 15, 2022)

covacat said:


> service routing will do the static ones



`service routing restart`, yes? 

There's an unfortunate side effect, *loss of TCP/IPv4 routing (DHCP)*: 


```
root@mowa219-gjp4-8570p-freebsd:~ # route -4 show default
   route to: default
destination: default
       mask: default
    gateway: 192.168.1.1
        fib: 0
  interface: em0
      flags: <UP,GATEWAY,DONE,STATIC>
 recvpipe  sendpipe  ssthresh  rtt,msec    mtu        weight    expire
       0         0         0         0      1500         1         0
root@mowa219-gjp4-8570p-freebsd:~ # route -6 show default
route: route has not been found
root@mowa219-gjp4-8570p-freebsd:~ # service routing restart
delete host 127.0.0.1: gateway lo0
default              192.168.1.1          -fib 0   done
delete host ::1: gateway lo0
delete net fe80::: gateway ::1
delete net ff02::: gateway ::1
delete net ::ffff:0.0.0.0: gateway ::1
delete net ::0.0.0.0: gateway ::1
route: route has not been found
delete net default: gateway ⋯:⋯:1f1c:a0::1 fib 0: not in table
add host 127.0.0.1: gateway lo0
add host ::1: gateway lo0
add net fe80::: gateway ::1
add net ff02::: gateway ::1
add net ::ffff:0.0.0.0: gateway ::1
add net ::0.0.0.0: gateway ::1
add net default: gateway 2001:470:1f1c:a0::1
root@mowa219-gjp4-8570p-freebsd:~ # route -4 show default
route: route has not been found
root@mowa219-gjp4-8570p-freebsd:~ # route -6 show default
   route to: default
destination: default
       mask: default
    gateway: tunnel⋯.tunnel.tserv1.lon2.ipv6.he.net
        fib: 0
  interface: gif0
      flags: <UP,GATEWAY,DONE,STATIC>
 recvpipe  sendpipe  ssthresh  rtt,msec    mtu        weight    expire
       0         0         0         0      1480         1         0
root@mowa219-gjp4-8570p-freebsd:~ #
```

A subsequent workaround regains the TCP/IPv4 route without losing the TCP/IPv6 route:

`service dhclient restart em0`


```
root@mowa219-gjp4-8570p-freebsd:~ # service dhclient restart em0
Stopping dhclient.
Waiting for PIDS: 11905.
Starting dhclient.
DHCPREQUEST on em0 to 255.255.255.255 port 67
DHCPACK from 192.168.1.1
bound to 192.168.1.10 -- renewal in 302400 seconds.
root@mowa219-gjp4-8570p-freebsd:~ # route -4 show default
   route to: default
destination: default
       mask: default
    gateway: 192.168.1.1
        fib: 0
  interface: em0
      flags: <UP,GATEWAY,DONE,STATIC>
 recvpipe  sendpipe  ssthresh  rtt,msec    mtu        weight    expire
       0         0         0         0      1500         1         0
root@mowa219-gjp4-8570p-freebsd:~ # route -6 show default
   route to: default
destination: default
       mask: default
    gateway: tunnel⋯.tunnel.tserv1.lon2.ipv6.he.net
        fib: 0
  interface: gif0
      flags: <UP,GATEWAY,DONE,STATIC>
 recvpipe  sendpipe  ssthresh  rtt,msec    mtu        weight    expire
       0         0         0         0      1480         1         0
root@mowa219-gjp4-8570p-freebsd:~ #
```

Can we improve upon this? 

Run things in a different order, maybe?


----------



## Incnis Mrsi (Jul 31, 2022)

grahamperrin@ said:


> I use the Hurricane Electric Free IPv6 Tunnel Broker service, most recently configured to work with my wired network at home.
> 
> gif(4), em(4).
> 
> Re: <https://forums.freebsd.org/posts/556270> I temporarily used Wi-Fi instead of a wired connection, to compare speeds.


This stuff is all the way insufficiently descriptive.

Where is FreeBSD: at the public IPv4 link or behind another device (router)?
If the latter, then is the router (NAT device) configured to route IPV6 (proto 41) toward the FreeBSD box or serves itself as a 6in4 endpoint? My experience showed that use of gif(4) behind NAT is not possible without fixing the source code (Thread how-i-built-a-module.76025), but such setup is indeed possible.
Was the “I temporarily” computer the same as the FreeBSD machine in question, or another one (that merely _used_ IPv6)?
If the former, then did “temporary use [of] Wi-Fi” involve downing of the Ethernet interface?
If the interface on which `gif0` depended died, then no surprise that the tunnel dissipated and did not respawn automatically. Learn to relate facts properly and present thoughts coherently. People unable or unwilling to do so use MacOS, Android, Microsoft Windows or Chromium OS.


----------

