diff --git a/docs/website/content/v0.6/en/configuration/v1alpha1.md b/docs/website/content/v0.6/en/configuration/v1alpha1.md index e36e1beb5..5e616573a 100644 --- a/docs/website/content/v0.6/en/configuration/v1alpha1.md +++ b/docs/website/content/v0.6/en/configuration/v1alpha1.md @@ -737,6 +737,11 @@ The following DHCP options are supported: `ignore` is used to exclude a specific interface from configuration. This parameter is optional. +##### machine.network.interfaces.dummy + +`dummy` is used to specify that this interface should be a virtual-only, dummy interface. +This parameter is optional. + ##### machine.network.interfaces.routes `routes` is used to specify static routes that may be necessary. diff --git a/internal/app/machined/pkg/runtime/configurator.go b/internal/app/machined/pkg/runtime/configurator.go index 76175cff2..14901f7f2 100644 --- a/internal/app/machined/pkg/runtime/configurator.go +++ b/internal/app/machined/pkg/runtime/configurator.go @@ -152,6 +152,7 @@ type Device struct { MTU int `yaml:"mtu"` DHCP bool `yaml:"dhcp"` Ignore bool `yaml:"ignore"` + Dummy bool `yaml:"dummy"` } // Bond contains the various options for configuring a diff --git a/internal/app/networkd/pkg/networkd/netconf.go b/internal/app/networkd/pkg/networkd/netconf.go index 8d3ca8bc2..67e8228e8 100644 --- a/internal/app/networkd/pkg/networkd/netconf.go +++ b/internal/app/networkd/pkg/networkd/netconf.go @@ -71,6 +71,11 @@ func buildOptions(device runtime.Device, hostname string) (name string, opts []n } } + // Handle dummy interface + if device.Dummy { + opts = append(opts, nic.WithDummy()) + } + // Configure Bonding if device.Bond == nil { return device.Interface, opts, err diff --git a/internal/app/networkd/pkg/nic/nic.go b/internal/app/networkd/pkg/nic/nic.go index 0dc939b20..7d194f8fc 100644 --- a/internal/app/networkd/pkg/nic/nic.go +++ b/internal/app/networkd/pkg/nic/nic.go @@ -45,6 +45,7 @@ type NetworkInterface struct { Name string Type int Ignore bool + Dummy bool Bonded bool MTU uint32 Link *net.Interface @@ -124,6 +125,10 @@ func (n *NetworkInterface) Create() error { info = &rtnetlink.LinkInfo{Kind: "bond"} } + if n.Dummy { + info = &rtnetlink.LinkInfo{Kind: "dummy"} + } + if err = n.createLink(n.Name, info); err != nil { return err } diff --git a/internal/app/networkd/pkg/nic/options.go b/internal/app/networkd/pkg/nic/options.go index 81dee920b..7fd8d0e50 100644 --- a/internal/app/networkd/pkg/nic/options.go +++ b/internal/app/networkd/pkg/nic/options.go @@ -23,6 +23,14 @@ func defaultOptions() *NetworkInterface { } } +// WithDummy indicates that the interface should be a virtual, dummy interface. +func WithDummy() Option { + return func(n *NetworkInterface) (err error) { + n.Dummy = true + return + } +} + // WithIgnore indicates that the interface should not be processed by talos. func WithIgnore() Option { return func(n *NetworkInterface) (err error) { diff --git a/pkg/config/types/v1alpha1/v1alpha1_types.go b/pkg/config/types/v1alpha1/v1alpha1_types.go index 7ece7287c..7e87519af 100644 --- a/pkg/config/types/v1alpha1/v1alpha1_types.go +++ b/pkg/config/types/v1alpha1/v1alpha1_types.go @@ -436,6 +436,11 @@ type NetworkConfig struct { // `ignore` is used to exclude a specific interface from configuration. // This parameter is optional. // + // ##### machine.network.interfaces.dummy + // + // `dummy` is used to specify that this interface should be a virtual-only, dummy interface. + // This parameter is optional. + // // ##### machine.network.interfaces.routes // // `routes` is used to specify static routes that may be necessary.