netmask/broadcast options are deprecated since buster
https://manpages.debian.org/buster/ifupdown/interfaces.5.en.html
This still read both "old address/netmask" or "address cidr" format,
but always convert it to cidr address format
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
# map address and netmask to cidr
if ($d->{address}) {
if ($d->{netmask} && $d->{netmask} =~ m/^\d+$/) { # e.g. netmask 20
# map address and netmask to cidr
if ($d->{address}) {
if ($d->{netmask} && $d->{netmask} =~ m/^\d+$/) { # e.g. netmask 20
- $d->{cidr} = $d->{address} . "/" . $d->{netmask};
+ $d->{address} = $d->{address} . "/" . $d->{netmask};
} elsif ($d->{netmask} &&
(my $cidr = PVE::JSONSchema::get_netmask_bits($d->{netmask}))) { # e.g. netmask 255.255.255.0
} elsif ($d->{netmask} &&
(my $cidr = PVE::JSONSchema::get_netmask_bits($d->{netmask}))) { # e.g. netmask 255.255.255.0
- $d->{cidr} = $d->{address} . "/" . $cidr;
- } elsif ($d->{address} =~ m!^(.*)/(\d+)$!) {
- $d->{cidr} = $d->{address};
- $d->{address} = $1;
- $d->{netmask} = $2;
- } else {
- $d->{cidr} = $d->{address};
+ $d->{address} = $d->{address} . "/" . $cidr;
+ #for api compatibility
+ $d->{cidr} = $d->{address}
}
# map address6 and netmask6 to cidr6
if ($d->{address6}) {
}
# map address6 and netmask6 to cidr6
if ($d->{address6}) {
- $d->{cidr6} = $d->{address6};
- if ($d->{netmask6}) {
- $d->{cidr6} .= "/" . $d->{netmask6};
- } elsif ($d->{address6} =~ m!^(.*)/(\d+)$!) {
- $d->{address6} = $1;
- $d->{netmask6} = $2;
- }
+ $d->{address6} .= "/" . $d->{netmask6} if $d->{address6} !~ m!^(.*)/(\d+)$! && $d->{netmask6};
+ #for api compatibility
+ $d->{cidr6} = $d->{address6}
}
$d->{method} = 'manual' if !$d->{method};
}
$d->{method} = 'manual' if !$d->{method};
$raw .= "iface $iface $family " . $d->{"method$suffix"} . "\n";
$raw .= "\taddress " . $d->{"address$suffix"} . "\n" if $d->{"address$suffix"};
$raw .= "iface $iface $family " . $d->{"method$suffix"} . "\n";
$raw .= "\taddress " . $d->{"address$suffix"} . "\n" if $d->{"address$suffix"};
- $raw .= "\tnetmask " . $d->{"netmask$suffix"} . "\n" if $d->{"netmask$suffix"};
$raw .= "\tgateway " . $d->{"gateway$suffix"} . "\n" if $d->{"gateway$suffix"};
$raw .= "\tgateway " . $d->{"gateway$suffix"} . "\n" if $d->{"gateway$suffix"};
- $raw .= "\tbroadcast " . $d->{"broadcast$suffix"} . "\n" if $d->{"broadcast$suffix"};
my $done = { type => 1, priority => 1, method => 1, active => 1, exists => 1,
comments => 1, autostart => 1, options => 1,
my $done = { type => 1, priority => 1, method => 1, active => 1, exists => 1,
comments => 1, autostart => 1, options => 1,
-my $ip = '10.0.0.2';
-my $nm = '255.255.255.0';
-my $ip6 = 'fc05::1:2';
-my $nm6 = '112';
+my $ip6 = 'fc05::1:2/112';
my $gw6 = 'fc05::1:1';
r(load('base'));
my $gw6 = 'fc05::1:1';
r(load('base'));
update_iface('vmbr0',
[ { family => 'inet',
address => $ip,
update_iface('vmbr0',
[ { family => 'inet',
address => $ip,
gateway => $gw } ],
autostart => 0);
expect load('base') . <<"EOF";
iface vmbr0 inet static
address $ip
gateway => $gw } ],
autostart => 0);
expect load('base') . <<"EOF";
iface vmbr0 inet static
address $ip
gateway $gw
bridge-ports eth0
bridge-stp off
gateway $gw
bridge-ports eth0
bridge-stp off
update_iface('vmbr0',
[ { family => 'inet6',
address => $ip6,
update_iface('vmbr0',
[ { family => 'inet6',
address => $ip6,
gateway => $gw6 } ]);
expect load('with-ipv4') . <<"EOF";
iface vmbr0 inet6 static
address $ip6
gateway => $gw6 } ]);
expect load('with-ipv4') . <<"EOF";
iface vmbr0 inet6 static
address $ip6
expect load('base') . <<"EOF";
iface vmbr0 inet6 static
address $ip6
expect load('base') . <<"EOF";
iface vmbr0 inet6 static
address $ip6
gateway $gw6
bridge-ports eth0
bridge-stp off
gateway $gw6
bridge-ports eth0
bridge-stp off
# Variables used for the various interfaces:
#
# Variables used for the various interfaces:
#
-my $ip = '192.168.0.2';
-my $nm = '255.255.255.0';
+my $ip = '192.168.0.2/24';
my $gw = '192.168.0.1';
my $svcnodeip = '239.192.105.237';
my $physdev = 'eth0';
my $gw = '192.168.0.1';
my $svcnodeip = '239.192.105.237';
my $physdev = 'eth0';
my $vmbr0_part = <<"PART";
auto vmbr0
iface vmbr0 inet static
my $vmbr0_part = <<"PART";
auto vmbr0
iface vmbr0 inet static
- address 10.0.0.2
- netmask 255.255.255.0
gateway 10.0.0.1
bridge-ports eth0
bridge-stp off
gateway 10.0.0.1
bridge-ports eth0
bridge-stp off
type => 'eth',
method => 'static',
address => $ip,
type => 'eth',
method => 'static',
address => $ip,
gateway => $gw,
families => ['inet'],
autostart => 1
gateway => $gw,
families => ['inet'],
autostart => 1
auto eth1
iface eth1 inet static
address $ip
auto eth1
iface eth1 inet static
address $ip
gateway $gw
PART
chomp $eth1_part;
gateway $gw
PART
chomp $eth1_part;
auto eth1
iface eth1 inet6 static
address $ip
auto eth1
iface eth1 inet6 static
address $ip
gateway $gw
iface eth2 inet manual
gateway $gw
iface eth2 inet manual
auto vmbr0
iface vmbr0 inet static
auto vmbr0
iface vmbr0 inet static
- address 10.0.0.2
- netmask 255.255.255.0
gateway 10.0.0.1
bridge-ports eth0
bridge-stp off
gateway 10.0.0.1
bridge-ports eth0
bridge-stp off
/proc/net/dev
my %wanted = (
/proc/net/dev
my %wanted = (
- vmbr0 => { address => '192.168.1.2',
- netmask => '255.255.255.0',
+ vmbr0 => { address => '192.168.1.2/24',
gateway => '192.168.1.1',
gateway => '192.168.1.1',
- address6 => 'fc05::1:1',
- netmask6 => '112' },
- vmbr1 => { address => '10.0.0.5',
- netmask => '255.255.255.0' }
+ address6 => 'fc05::1:1/112'},
+ vmbr1 => { address => '10.0.0.5/24'}
);
save('interfaces', <<"/etc/network/interfaces");
);
save('interfaces', <<"/etc/network/interfaces");
auto vmbr0
iface vmbr0 inet static
auto vmbr0
iface vmbr0 inet static
- address $wanted{vmbr0}->{address}
- netmask $wanted{vmbr0}->{netmask}
+ address 192.168.1.2
+ netmask 24
gateway $wanted{vmbr0}->{gateway}
bridge_ports eth0
bridge_stp off
bridge_fd 0
iface vmbr0 inet6 static
gateway $wanted{vmbr0}->{gateway}
bridge_ports eth0
bridge_stp off
bridge_fd 0
iface vmbr0 inet6 static
- address $wanted{vmbr0}->{address6}
- netmask $wanted{vmbr0}->{netmask6}
+ address fc05::1:1
+ netmask 112
source-directory before-ovs.d
allow-ovs vmbr1
iface vmbr1 inet static
source-directory before-ovs.d
allow-ovs vmbr1
iface vmbr1 inet static
- address $wanted{vmbr1}->{address}
- netmask $wanted{vmbr1}->{netmask}
+ address 10.0.0.5
+ netmask 255.255.255.0
ovs_type OVSBridge
ovs_ports eth100
ovs_type OVSBridge
ovs_ports eth100
-my $ip = '192.168.0.100';
-my $nm = '255.255.255.0';
+my $ip = '192.168.0.100/24';
my $gw = '192.168.0.1';
# replace proc_net_dev with one with a bunch of interfaces
my $gw = '192.168.0.1';
# replace proc_net_dev with one with a bunch of interfaces
new_iface('vmbr0', 'OVSBridge',
[ { family => 'inet',
address => $ip,
new_iface('vmbr0', 'OVSBridge',
[ { family => 'inet',
address => $ip,
gateway => $gw } ],
autostart => 1);
gateway => $gw } ],
autostart => 1);
allow-ovs vmbr0
iface vmbr0 inet static
address $ip
allow-ovs vmbr0
iface vmbr0 inet static
address $ip
gateway $gw
ovs_type OVSBridge
gateway $gw
ovs_type OVSBridge
allow-ovs vmbr0
iface vmbr0 inet static
address $ip
allow-ovs vmbr0
iface vmbr0 inet static
address $ip
gateway $gw
ovs_type OVSBridge
ovs_ports eth1 eth2
gateway $gw
ovs_type OVSBridge
ovs_ports eth1 eth2
allow-ovs vmbr0
iface vmbr0 inet static
address $ip
allow-ovs vmbr0
iface vmbr0 inet static
address $ip
gateway $gw
ovs_type OVSBridge
ovs_ports eth1
gateway $gw
ovs_type OVSBridge
ovs_ports eth1
auto vmbr0
iface vmbr0 inet static
auto vmbr0
iface vmbr0 inet static
- address 10.0.0.2
- netmask 255.255.255.0
gateway 10.0.0.1
bridge-ports eth0
bridge-stp off
gateway 10.0.0.1
bridge-ports eth0
bridge-stp off
auto bond1
iface bond1 inet static
auto bond1
iface bond1 inet static
- address 10.10.10.$ip
- netmask 255.255.255.0
+ address 10.10.10.$ip/24
bond-slaves eth2 eth3
bond-miimon 100
bond-mode balance-alb
bond-slaves eth2 eth3
bond-miimon 100
bond-mode balance-alb
iface unknown3 inet static
address 0.0.0.0
iface unknown3 inet static
address 0.0.0.0
iface unknown4 inet static
address 0.0.0.0
iface unknown4 inet static
address 0.0.0.0
iface unknown5 inet static
address 0.0.0.0
iface unknown5 inet static
address 0.0.0.0
auto vmbr0
iface vmbr0 inet static
auto vmbr0
iface vmbr0 inet static
- address 192.168.100.13
- netmask 255.255.255.0
+ address 192.168.100.13/24
gateway 192.168.100.1
bridge-ports bond0
bridge-stp off
gateway 192.168.100.1
bridge-ports bond0
bridge-stp off
auto unknown6
iface unknown6 inet static
auto unknown6
iface unknown6 inet static
- address 10.10.11.13
- netmask 255.255.255.0
- network 10.10.11.0
pre-up ifconfig bond0 up
auto vmbr3
pre-up ifconfig bond0 up
auto vmbr3
-update_iface('bond1', [ { family => 'inet', address => '10.10.10.11' } ]);
+update_iface('bond1', [ { family => 'inet', address => '10.10.10.11/24' } ]);
-my $ip = '192.168.0.2';
-my $nm = '255.255.255.0';
+my $ip = '192.168.0.2/24';
-my $ip6 = 'fc05::2';
-my $nm6 = '112';
+my $ip6 = 'fc05::2/112';
my $gw6 = 'fc05::1';
# Load
my $gw6 = 'fc05::1';
# Load
type => 'eth',
method => 'static',
address => $ip,
type => 'eth',
method => 'static',
address => $ip,
gateway => $gw,
families => ['inet'],
autostart => 1
gateway => $gw,
families => ['inet'],
autostart => 1
auto eth1
iface eth1 inet static
address $ip
auto eth1
iface eth1 inet static
address $ip
gateway $gw
auto vmbr0
iface vmbr0 inet static
gateway $gw
auto vmbr0
iface vmbr0 inet static
- address 10.0.0.2
- netmask 255.255.255.0
gateway 10.0.0.1
bridge-ports eth0
bridge-stp off
gateway 10.0.0.1
bridge-ports eth0
bridge-stp off
auto eth1
iface eth1 inet static
address $ip
auto eth1
iface eth1 inet static
address $ip
gateway $gw
iface eth1 inet6 static
address $ip6
gateway $gw
iface eth1 inet6 static
address $ip6
gateway $gw6
auto vmbr0
iface vmbr0 inet static
gateway $gw6
auto vmbr0
iface vmbr0 inet static
- address 10.0.0.2
- netmask 255.255.255.0
gateway 10.0.0.1
bridge-ports eth0
bridge-stp off
gateway 10.0.0.1
bridge-ports eth0
bridge-stp off