setting up a v4tunnel interface after a dhcp interface?

Caleb enlightened.despot at gmail.com
Tue Nov 17 18:12:23 UTC 2015


I haven't tested this, so your mileage may vary, but I believe you can
handle this by removing the "auto he0" line so that the he0 interface
isn't brought up automatically, then adding an 'up' command to the
eth0 interface definition:

auto eth0
iface eth0 inet dhcp
    up ifup he0

One potential snag: if I remember correctly, an interface being "up"
is separate and distinct from an interface having obtained a
dynamically assigned IP address, so /etc/network/if-up.d/he might
still be executed while the DHCP request is still in process, and
_before_ eth0 has obtained an IP address. This potential race
condition could be resolved by a static address assignment.

Alternatively, I believe--but have not verified--that Upstart's
'net-device-up' isn't triggered until the interface has a valid IP
address. If so, an Upstart script like the following should work
(adapted from http://serverfault.com/questions/117584/upstart-scripts-run-a-task-after-networking-goes-up):

respawn
console none

start on (local-filesystems and net-device-up IFACE!=lo)
stop on [!12345]

script
ifup he0
end script

This script needs to be in /etc/init and have a .conf extension.
/etc/init/he.conf would be a good name for it.

Even if the Upstart approach works, you'll eventually have to change
it because of the move from Upstart to systemd
(http://www.markshuttleworth.com/archives/1316).

HTH,
-Caleb

On Tue, Nov 17, 2015 at 12:55 AM, Ben Coleman <oloryn at benshome.net> wrote:
> I've got a couple of Ubuntu 14.04 VPSs where the eth0 interface gets its
> ipv4 address via dhcp.  This is set up as
>
> auto eth0
> iface eth0 inet dhcp
>
> in a file in /etc/network/interface.d.  They always get the same ip
> address, but this is how the VPS vendor has set them up.
>
> I've also set up Hurricane Electric tunnels for them for ipv6, set up as
> the typical
>
> auto he0
> iface he0 inet6 v4tunnel
>         address <my ipv6 address>
>         netmask 64
>         endpoint <endpoint ipv4 address - which is the same as the eth0
> ip address>
>         local <local ipv4 address>
>         ttl 255
>         gateway <gateway ipv6 address>
>
> What I'm finding is that on boot-up, while the he0 interface is created,
> it does not have the global scope ipv6 address attached (same address as
> specified in <my ipv6 address> above).  I can do a
>
> sudo ifdown he0; sudo ifup he0
>
> and it will be correct, but it does not come up correctly on boot-up.
>
> I believe this is because during boot-up, he0 is being set up while the
> dhcp process is still going on, and eth0 does not yet have an ip
> address.  The ipv6 connection does not get set up because the eth0 ip
> address does not yet match the endpoint address of eth0.
>
> So, is there a way to specify that the he0 interface should not be set
> up until after eth0 has completed dhcp?
>
> Ben
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users



More information about the ubuntu-users mailing list