OpenNebula / addon-context-linux

Linux VM Contextualization
Apache License 2.0
56 stars 73 forks source link

DHCP configured interfaces #86

Closed vholer closed 3 years ago

vholer commented 6 years ago

There are situations where both statically and dynamically (e.g. when using just ethernet ranges) configured network interfaces are used. Currently, the scripts can work fine with one or the other, but not well with both at the same time.

rvalle commented 6 years ago

You seem to imply that DHCP works when using an Ethernet Address Reservation with this contextualization package, how?

I am trying to setup a virtual router where the "external" interface is setup with DHCP and requieres an specific Ethernet Address Reservation, and the "internal" interface is an IP address reservation.

Is this the case you are referring in this issue?

I don't see how to use DHCP at all with the contextualization package. I am considering doing something form a contextualization script.

atodorov-storpool commented 6 years ago

@rvalle,

defining a network configuration with all but IP and IP6 fields left empty will not override the interface configuration files

https://github.com/OpenNebula/addon-context-linux/blob/master/src/etc/one-context.d/loc-10-network%23%23rpm.one#L205

rvalle commented 6 years ago

Yes, but that won't autoconfigue the DHCP interface, right?

I mean, the default /etc/interfaces files in debian will only configure the loopback

Do you mean that then I should also use contextualization to setup the interface files?

vholer commented 3 years ago

This issue is planned to be covered during the refactoring of network scripts to provide more flexibility. New interface context variables will be introduced ETHx_METHOD and ETHx_IP6_METHOD to describe the way how interface is configured in guest. Following values will be understood:

ETH1_METHOD="static"
ETH1_IP6_METHOD="disable"

Guest Network Configuration

Only a relevant snippets follows about how to configure various guest OSes ...

RedHat network-scripts

Use

IPV6INIT=yes
IPV6_AUTOCONF=yes

Use

IPV6INIT=yes
IPV6_AUTOCONF=yes
DHCPV6C=yes

Only when IPv4 is configured (otherwise skip):

echo net.ipv6.conf.eth1.disable_ipv6=1 >>/etc/sysctl.conf
sysctl net.ipv6.conf.eth1.disable_ipv6=1

Debian interfaces

Use

iface eth1 inet6 auto

Use

iface eth1 inet6 dhcp

Only when IPv4 is configured (otherwise skip):

iface eth1 inet dhcp
  pre-up echo 1 > /proc/sys/net/ipv6/conf/eth1/disable_ipv6

Netplan

Use

    eth1:
      accept-ra: true
      dhcp6: false

:warning: Combination of netplan+networkd doesn't completely disable DHCPv6, as it can still be triggered if relevant flags are in RA data.

Use

  ethernets:
    eth1:
      accept-ra: true    
      dhcp6: true

Only when IPv4 is configured (otherwise skip):

  ethernets:
    eth1:
      accept-ra: false
      link-local: [ ]

NetworkManager

(see https://unix.stackexchange.com/questions/440076/disable-dhcpv6-while-not-disabling-slaac-in-network-manager)

nmcli c mod $DEV ipv6.method ignore
nmcli c mod $DEV ipv6.method dhcp

:warning: Netplan puts into auto. Review!

nmcli c mod $DEV ipv6.method disabled

systemd-networkd

If ETHx_IP6_METHOD="dhcp", use

[Network]
DHCP=true

otherwise

[Network]
DHCP=ipv4

If ETHx_METHOD="dhcp"

[Network]
DHCP=ipv4
IPv6AcceptRA=yes

[IPv6AcceptRA]
DHCPv6Client=no

otherwise

[Network]
DHCP=false
IPv6AcceptRA=yes

[IPv6AcceptRA]
DHCPv6Client=no

If ETHx_METHOD="dhcp"

[Network]
DHCP=true
IPv6AcceptRA=yes

else

[Network]
DHCP=ipv6
IPv6AcceptRA=yes

Only when IPv4 is configured (otherwise skip):

[Network]
LinkLocalAddressing=no
IPv6AcceptRA=no
vholer commented 3 years ago

Implemented as part of #227.

Leaving opened as we need update in oned.conf to inherit the METHOD context variables frim NIC/VNET.

vholer commented 3 years ago

Selectable guest NIC configuration methods implemented in master.

Short description with supported combinations and few OS quirks: https://github.com/OpenNebula/addon-context-linux/blob/d5e3d3ac93607192cdd85b48cb56e9cf186cbd7b/README.md#guest-network-configuration-since-6180