How to add a static secondary IP to a DHCP interface using netplan?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
My server has a file /etc/netplan/50-cloud-init.yaml with the following content:
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: config: disabled
network:
version: 2
ethernets:
ens3:
dhcp4: true
match:
macaddress: fa:**:**:**:**:**
set-name: ens3
This results in the following interface configuration:
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc fq_codel state UP group default qlen 1000
link/ether fa:**:**:**:**:** brd ff:ff:ff:ff:ff:ff
inet 10.0.0.5/24 brd 10.0.0.255 scope global dynamic ens3
...
So far, so good. But now I need to add 10.0.0.250 as an additional secondary static IP to this interface. What is the best way to do that? I created a new file /etc/netplan/60-service-ip.yaml with:
network:
version: 2
ethernets:
ens3:
addresses:
- 10.0.0.5/24
- 10.0.0.250/24
This seems to work, but it re-defines a dynamic IP as a static one.
linux-networking dhcp static-ip netplan
add a comment |Â
up vote
1
down vote
favorite
My server has a file /etc/netplan/50-cloud-init.yaml with the following content:
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: config: disabled
network:
version: 2
ethernets:
ens3:
dhcp4: true
match:
macaddress: fa:**:**:**:**:**
set-name: ens3
This results in the following interface configuration:
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc fq_codel state UP group default qlen 1000
link/ether fa:**:**:**:**:** brd ff:ff:ff:ff:ff:ff
inet 10.0.0.5/24 brd 10.0.0.255 scope global dynamic ens3
...
So far, so good. But now I need to add 10.0.0.250 as an additional secondary static IP to this interface. What is the best way to do that? I created a new file /etc/netplan/60-service-ip.yaml with:
network:
version: 2
ethernets:
ens3:
addresses:
- 10.0.0.5/24
- 10.0.0.250/24
This seems to work, but it re-defines a dynamic IP as a static one.
linux-networking dhcp static-ip netplan
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
My server has a file /etc/netplan/50-cloud-init.yaml with the following content:
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: config: disabled
network:
version: 2
ethernets:
ens3:
dhcp4: true
match:
macaddress: fa:**:**:**:**:**
set-name: ens3
This results in the following interface configuration:
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc fq_codel state UP group default qlen 1000
link/ether fa:**:**:**:**:** brd ff:ff:ff:ff:ff:ff
inet 10.0.0.5/24 brd 10.0.0.255 scope global dynamic ens3
...
So far, so good. But now I need to add 10.0.0.250 as an additional secondary static IP to this interface. What is the best way to do that? I created a new file /etc/netplan/60-service-ip.yaml with:
network:
version: 2
ethernets:
ens3:
addresses:
- 10.0.0.5/24
- 10.0.0.250/24
This seems to work, but it re-defines a dynamic IP as a static one.
linux-networking dhcp static-ip netplan
My server has a file /etc/netplan/50-cloud-init.yaml with the following content:
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: config: disabled
network:
version: 2
ethernets:
ens3:
dhcp4: true
match:
macaddress: fa:**:**:**:**:**
set-name: ens3
This results in the following interface configuration:
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc fq_codel state UP group default qlen 1000
link/ether fa:**:**:**:**:** brd ff:ff:ff:ff:ff:ff
inet 10.0.0.5/24 brd 10.0.0.255 scope global dynamic ens3
...
So far, so good. But now I need to add 10.0.0.250 as an additional secondary static IP to this interface. What is the best way to do that? I created a new file /etc/netplan/60-service-ip.yaml with:
network:
version: 2
ethernets:
ens3:
addresses:
- 10.0.0.5/24
- 10.0.0.250/24
This seems to work, but it re-defines a dynamic IP as a static one.
linux-networking dhcp static-ip netplan
linux-networking dhcp static-ip netplan
asked 49 mins ago
Torsten Bronger
1277
1277
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
Answered on Ask Ubuntu
Copy:
The solution was quite simple, just set a static IP address and enable DHCP. Basically you just have to add dhcp4: yes
to your configuration.
This configuration gave me a primary static IP address and a secondary DHCP assigned IP address:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
dhcp6: no
addresses:
- 10.1.2.15/24
gateway4: 10.1.2.1
nameservers:
search:
- example.com
addresses: [10.1.2.10]
The result of ip address show enp0s3 gave me:
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:ab:cd:ef brd ff:ff:ff:ff:ff:ff
inet 10.1.2.15/24 brd 10.0.1.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet 10.1.2.96/24 brd 10.0.1.255 scope global secondary dynamic enp0s3
valid_lft 3224sec preferred_lft 3224sec
inet6 fe80::a00:27ff:fe20:2c40/64 scope link
valid_lft forever preferred_lft forever
The address 10.1.2.96 is the secondary DHCP assigned address as indicated by the secondary dynamic keywords.
Unfortunately, this results in the DHCP address being the secondary address. However, it needs to be primary in order to make outgoing connections work.
– Torsten Bronger
17 mins ago
Why does it have to be primary? Are you sure you don't just need source routing? or a different gateway per IP?
– Lenniey
10 mins ago
If the DHCP-based address is primary, everything works fine. If it is secondary, outgoing connections hang. See also bugs.launchpad.net/netplan/+bug/1766656, especially comment #2.
– Torsten Bronger
5 mins ago
add a comment |Â
up vote
1
down vote
It's actually way easier, you just add dhcp4: true
to your static configuration like this (and disable v6 if you don't need it):
network:
version: 2
ethernets:
ens3:
dhcp4: yes
dhcp6: no
addresses:
- 10.0.0.5/24
- 10.0.0.250/24
Here, I still have to make the dynamic 10.0.0.5 a static one.
– Torsten Bronger
16 mins ago
That's exactly what this does, you have two static addresses 10.0.0.5/24 and 10.0.0.250/24 and get an additional dynamic ip.
– Broco
13 mins ago
But 10.0.0.5 comes from the DHCP server and I don’t know its value a priori.
– Torsten Bronger
4 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Answered on Ask Ubuntu
Copy:
The solution was quite simple, just set a static IP address and enable DHCP. Basically you just have to add dhcp4: yes
to your configuration.
This configuration gave me a primary static IP address and a secondary DHCP assigned IP address:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
dhcp6: no
addresses:
- 10.1.2.15/24
gateway4: 10.1.2.1
nameservers:
search:
- example.com
addresses: [10.1.2.10]
The result of ip address show enp0s3 gave me:
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:ab:cd:ef brd ff:ff:ff:ff:ff:ff
inet 10.1.2.15/24 brd 10.0.1.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet 10.1.2.96/24 brd 10.0.1.255 scope global secondary dynamic enp0s3
valid_lft 3224sec preferred_lft 3224sec
inet6 fe80::a00:27ff:fe20:2c40/64 scope link
valid_lft forever preferred_lft forever
The address 10.1.2.96 is the secondary DHCP assigned address as indicated by the secondary dynamic keywords.
Unfortunately, this results in the DHCP address being the secondary address. However, it needs to be primary in order to make outgoing connections work.
– Torsten Bronger
17 mins ago
Why does it have to be primary? Are you sure you don't just need source routing? or a different gateway per IP?
– Lenniey
10 mins ago
If the DHCP-based address is primary, everything works fine. If it is secondary, outgoing connections hang. See also bugs.launchpad.net/netplan/+bug/1766656, especially comment #2.
– Torsten Bronger
5 mins ago
add a comment |Â
up vote
1
down vote
Answered on Ask Ubuntu
Copy:
The solution was quite simple, just set a static IP address and enable DHCP. Basically you just have to add dhcp4: yes
to your configuration.
This configuration gave me a primary static IP address and a secondary DHCP assigned IP address:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
dhcp6: no
addresses:
- 10.1.2.15/24
gateway4: 10.1.2.1
nameservers:
search:
- example.com
addresses: [10.1.2.10]
The result of ip address show enp0s3 gave me:
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:ab:cd:ef brd ff:ff:ff:ff:ff:ff
inet 10.1.2.15/24 brd 10.0.1.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet 10.1.2.96/24 brd 10.0.1.255 scope global secondary dynamic enp0s3
valid_lft 3224sec preferred_lft 3224sec
inet6 fe80::a00:27ff:fe20:2c40/64 scope link
valid_lft forever preferred_lft forever
The address 10.1.2.96 is the secondary DHCP assigned address as indicated by the secondary dynamic keywords.
Unfortunately, this results in the DHCP address being the secondary address. However, it needs to be primary in order to make outgoing connections work.
– Torsten Bronger
17 mins ago
Why does it have to be primary? Are you sure you don't just need source routing? or a different gateway per IP?
– Lenniey
10 mins ago
If the DHCP-based address is primary, everything works fine. If it is secondary, outgoing connections hang. See also bugs.launchpad.net/netplan/+bug/1766656, especially comment #2.
– Torsten Bronger
5 mins ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Answered on Ask Ubuntu
Copy:
The solution was quite simple, just set a static IP address and enable DHCP. Basically you just have to add dhcp4: yes
to your configuration.
This configuration gave me a primary static IP address and a secondary DHCP assigned IP address:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
dhcp6: no
addresses:
- 10.1.2.15/24
gateway4: 10.1.2.1
nameservers:
search:
- example.com
addresses: [10.1.2.10]
The result of ip address show enp0s3 gave me:
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:ab:cd:ef brd ff:ff:ff:ff:ff:ff
inet 10.1.2.15/24 brd 10.0.1.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet 10.1.2.96/24 brd 10.0.1.255 scope global secondary dynamic enp0s3
valid_lft 3224sec preferred_lft 3224sec
inet6 fe80::a00:27ff:fe20:2c40/64 scope link
valid_lft forever preferred_lft forever
The address 10.1.2.96 is the secondary DHCP assigned address as indicated by the secondary dynamic keywords.
Answered on Ask Ubuntu
Copy:
The solution was quite simple, just set a static IP address and enable DHCP. Basically you just have to add dhcp4: yes
to your configuration.
This configuration gave me a primary static IP address and a secondary DHCP assigned IP address:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
dhcp6: no
addresses:
- 10.1.2.15/24
gateway4: 10.1.2.1
nameservers:
search:
- example.com
addresses: [10.1.2.10]
The result of ip address show enp0s3 gave me:
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:ab:cd:ef brd ff:ff:ff:ff:ff:ff
inet 10.1.2.15/24 brd 10.0.1.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet 10.1.2.96/24 brd 10.0.1.255 scope global secondary dynamic enp0s3
valid_lft 3224sec preferred_lft 3224sec
inet6 fe80::a00:27ff:fe20:2c40/64 scope link
valid_lft forever preferred_lft forever
The address 10.1.2.96 is the secondary DHCP assigned address as indicated by the secondary dynamic keywords.
answered 39 mins ago
Lenniey
1,9452718
1,9452718
Unfortunately, this results in the DHCP address being the secondary address. However, it needs to be primary in order to make outgoing connections work.
– Torsten Bronger
17 mins ago
Why does it have to be primary? Are you sure you don't just need source routing? or a different gateway per IP?
– Lenniey
10 mins ago
If the DHCP-based address is primary, everything works fine. If it is secondary, outgoing connections hang. See also bugs.launchpad.net/netplan/+bug/1766656, especially comment #2.
– Torsten Bronger
5 mins ago
add a comment |Â
Unfortunately, this results in the DHCP address being the secondary address. However, it needs to be primary in order to make outgoing connections work.
– Torsten Bronger
17 mins ago
Why does it have to be primary? Are you sure you don't just need source routing? or a different gateway per IP?
– Lenniey
10 mins ago
If the DHCP-based address is primary, everything works fine. If it is secondary, outgoing connections hang. See also bugs.launchpad.net/netplan/+bug/1766656, especially comment #2.
– Torsten Bronger
5 mins ago
Unfortunately, this results in the DHCP address being the secondary address. However, it needs to be primary in order to make outgoing connections work.
– Torsten Bronger
17 mins ago
Unfortunately, this results in the DHCP address being the secondary address. However, it needs to be primary in order to make outgoing connections work.
– Torsten Bronger
17 mins ago
Why does it have to be primary? Are you sure you don't just need source routing? or a different gateway per IP?
– Lenniey
10 mins ago
Why does it have to be primary? Are you sure you don't just need source routing? or a different gateway per IP?
– Lenniey
10 mins ago
If the DHCP-based address is primary, everything works fine. If it is secondary, outgoing connections hang. See also bugs.launchpad.net/netplan/+bug/1766656, especially comment #2.
– Torsten Bronger
5 mins ago
If the DHCP-based address is primary, everything works fine. If it is secondary, outgoing connections hang. See also bugs.launchpad.net/netplan/+bug/1766656, especially comment #2.
– Torsten Bronger
5 mins ago
add a comment |Â
up vote
1
down vote
It's actually way easier, you just add dhcp4: true
to your static configuration like this (and disable v6 if you don't need it):
network:
version: 2
ethernets:
ens3:
dhcp4: yes
dhcp6: no
addresses:
- 10.0.0.5/24
- 10.0.0.250/24
Here, I still have to make the dynamic 10.0.0.5 a static one.
– Torsten Bronger
16 mins ago
That's exactly what this does, you have two static addresses 10.0.0.5/24 and 10.0.0.250/24 and get an additional dynamic ip.
– Broco
13 mins ago
But 10.0.0.5 comes from the DHCP server and I don’t know its value a priori.
– Torsten Bronger
4 mins ago
add a comment |Â
up vote
1
down vote
It's actually way easier, you just add dhcp4: true
to your static configuration like this (and disable v6 if you don't need it):
network:
version: 2
ethernets:
ens3:
dhcp4: yes
dhcp6: no
addresses:
- 10.0.0.5/24
- 10.0.0.250/24
Here, I still have to make the dynamic 10.0.0.5 a static one.
– Torsten Bronger
16 mins ago
That's exactly what this does, you have two static addresses 10.0.0.5/24 and 10.0.0.250/24 and get an additional dynamic ip.
– Broco
13 mins ago
But 10.0.0.5 comes from the DHCP server and I don’t know its value a priori.
– Torsten Bronger
4 mins ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
It's actually way easier, you just add dhcp4: true
to your static configuration like this (and disable v6 if you don't need it):
network:
version: 2
ethernets:
ens3:
dhcp4: yes
dhcp6: no
addresses:
- 10.0.0.5/24
- 10.0.0.250/24
It's actually way easier, you just add dhcp4: true
to your static configuration like this (and disable v6 if you don't need it):
network:
version: 2
ethernets:
ens3:
dhcp4: yes
dhcp6: no
addresses:
- 10.0.0.5/24
- 10.0.0.250/24
answered 38 mins ago
Broco
1,235618
1,235618
Here, I still have to make the dynamic 10.0.0.5 a static one.
– Torsten Bronger
16 mins ago
That's exactly what this does, you have two static addresses 10.0.0.5/24 and 10.0.0.250/24 and get an additional dynamic ip.
– Broco
13 mins ago
But 10.0.0.5 comes from the DHCP server and I don’t know its value a priori.
– Torsten Bronger
4 mins ago
add a comment |Â
Here, I still have to make the dynamic 10.0.0.5 a static one.
– Torsten Bronger
16 mins ago
That's exactly what this does, you have two static addresses 10.0.0.5/24 and 10.0.0.250/24 and get an additional dynamic ip.
– Broco
13 mins ago
But 10.0.0.5 comes from the DHCP server and I don’t know its value a priori.
– Torsten Bronger
4 mins ago
Here, I still have to make the dynamic 10.0.0.5 a static one.
– Torsten Bronger
16 mins ago
Here, I still have to make the dynamic 10.0.0.5 a static one.
– Torsten Bronger
16 mins ago
That's exactly what this does, you have two static addresses 10.0.0.5/24 and 10.0.0.250/24 and get an additional dynamic ip.
– Broco
13 mins ago
That's exactly what this does, you have two static addresses 10.0.0.5/24 and 10.0.0.250/24 and get an additional dynamic ip.
– Broco
13 mins ago
But 10.0.0.5 comes from the DHCP server and I don’t know its value a priori.
– Torsten Bronger
4 mins ago
But 10.0.0.5 comes from the DHCP server and I don’t know its value a priori.
– Torsten Bronger
4 mins ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f933576%2fhow-to-add-a-static-secondary-ip-to-a-dhcp-interface-using-netplan%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password