Detecting whether netplan is managing network config (shell)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
I would like to figure out in a shell script in an LXD container, whether the container is being managed by Netplan. This can be a bit of an unknown as I have a mix of 16.04 systems 18.04 systems and upgraded 18.04 systems.
In order to write correct network config to the container, I need to detect if the config is static in /etc/network/interfaces
or in a Netplan yaml file.
I could really use something like netplan status
but since that command does not exist I need alternatives.
I have asked around a fair bit, and there seems to be no official way.The suggestions I have had so far:
cat /etc/network/interfaces
and look for the Netplan info message there. I don't like this approach, as this would obviously be prone to breakage.- Someone suggested I could just look for /etc/netplan - but that will not work on upgraded systems as there Netplan is disabled but still installed.
- Another suggestion was the inverse: that I could check if ifupdown or systemd is managing the network. Problem is, I am not sure how to do this in a practical sense.
networking network-manager 18.04 netplan
add a comment |Â
up vote
1
down vote
favorite
I would like to figure out in a shell script in an LXD container, whether the container is being managed by Netplan. This can be a bit of an unknown as I have a mix of 16.04 systems 18.04 systems and upgraded 18.04 systems.
In order to write correct network config to the container, I need to detect if the config is static in /etc/network/interfaces
or in a Netplan yaml file.
I could really use something like netplan status
but since that command does not exist I need alternatives.
I have asked around a fair bit, and there seems to be no official way.The suggestions I have had so far:
cat /etc/network/interfaces
and look for the Netplan info message there. I don't like this approach, as this would obviously be prone to breakage.- Someone suggested I could just look for /etc/netplan - but that will not work on upgraded systems as there Netplan is disabled but still installed.
- Another suggestion was the inverse: that I could check if ifupdown or systemd is managing the network. Problem is, I am not sure how to do this in a practical sense.
networking network-manager 18.04 netplan
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I would like to figure out in a shell script in an LXD container, whether the container is being managed by Netplan. This can be a bit of an unknown as I have a mix of 16.04 systems 18.04 systems and upgraded 18.04 systems.
In order to write correct network config to the container, I need to detect if the config is static in /etc/network/interfaces
or in a Netplan yaml file.
I could really use something like netplan status
but since that command does not exist I need alternatives.
I have asked around a fair bit, and there seems to be no official way.The suggestions I have had so far:
cat /etc/network/interfaces
and look for the Netplan info message there. I don't like this approach, as this would obviously be prone to breakage.- Someone suggested I could just look for /etc/netplan - but that will not work on upgraded systems as there Netplan is disabled but still installed.
- Another suggestion was the inverse: that I could check if ifupdown or systemd is managing the network. Problem is, I am not sure how to do this in a practical sense.
networking network-manager 18.04 netplan
I would like to figure out in a shell script in an LXD container, whether the container is being managed by Netplan. This can be a bit of an unknown as I have a mix of 16.04 systems 18.04 systems and upgraded 18.04 systems.
In order to write correct network config to the container, I need to detect if the config is static in /etc/network/interfaces
or in a Netplan yaml file.
I could really use something like netplan status
but since that command does not exist I need alternatives.
I have asked around a fair bit, and there seems to be no official way.The suggestions I have had so far:
cat /etc/network/interfaces
and look for the Netplan info message there. I don't like this approach, as this would obviously be prone to breakage.- Someone suggested I could just look for /etc/netplan - but that will not work on upgraded systems as there Netplan is disabled but still installed.
- Another suggestion was the inverse: that I could check if ifupdown or systemd is managing the network. Problem is, I am not sure how to do this in a practical sense.
networking network-manager 18.04 netplan
asked May 8 at 13:52
Arni J
153
153
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
You may be able to check for the ifstate file from ifupdown, which will tell you whether that's what was used to configure the network:
/run/network/ifstate
If that's there and it contains text, you can expect that ifupdown is in use. If it's not present, the system is likely managed via netplan (but that won't tell you whether it's NetworkManager or systemd)
Then, if you want to know what backend is used for a particular interface, you can ask netplan, and parse the output to get the information you need:
netplan generate --mapping enp3s0
It outputs text like this:
id=enp3s0, backend=NetworkManager, set_name=(null), match_name=enp3s0, match_mac=(null), match_driver=(null)
That way you can also know using what matching rules the interface was configured (you use the "final" name of an interface to check the mapping, it tells you what matching rule is in the netplan YAML that matches for it).
Thank you for your thorough reply. I am now looking for /run/network/ifstate to ascertain what network config to write, and everything seems to work well :)
â Arni J
May 13 at 19:49
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You may be able to check for the ifstate file from ifupdown, which will tell you whether that's what was used to configure the network:
/run/network/ifstate
If that's there and it contains text, you can expect that ifupdown is in use. If it's not present, the system is likely managed via netplan (but that won't tell you whether it's NetworkManager or systemd)
Then, if you want to know what backend is used for a particular interface, you can ask netplan, and parse the output to get the information you need:
netplan generate --mapping enp3s0
It outputs text like this:
id=enp3s0, backend=NetworkManager, set_name=(null), match_name=enp3s0, match_mac=(null), match_driver=(null)
That way you can also know using what matching rules the interface was configured (you use the "final" name of an interface to check the mapping, it tells you what matching rule is in the netplan YAML that matches for it).
Thank you for your thorough reply. I am now looking for /run/network/ifstate to ascertain what network config to write, and everything seems to work well :)
â Arni J
May 13 at 19:49
add a comment |Â
up vote
2
down vote
accepted
You may be able to check for the ifstate file from ifupdown, which will tell you whether that's what was used to configure the network:
/run/network/ifstate
If that's there and it contains text, you can expect that ifupdown is in use. If it's not present, the system is likely managed via netplan (but that won't tell you whether it's NetworkManager or systemd)
Then, if you want to know what backend is used for a particular interface, you can ask netplan, and parse the output to get the information you need:
netplan generate --mapping enp3s0
It outputs text like this:
id=enp3s0, backend=NetworkManager, set_name=(null), match_name=enp3s0, match_mac=(null), match_driver=(null)
That way you can also know using what matching rules the interface was configured (you use the "final" name of an interface to check the mapping, it tells you what matching rule is in the netplan YAML that matches for it).
Thank you for your thorough reply. I am now looking for /run/network/ifstate to ascertain what network config to write, and everything seems to work well :)
â Arni J
May 13 at 19:49
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You may be able to check for the ifstate file from ifupdown, which will tell you whether that's what was used to configure the network:
/run/network/ifstate
If that's there and it contains text, you can expect that ifupdown is in use. If it's not present, the system is likely managed via netplan (but that won't tell you whether it's NetworkManager or systemd)
Then, if you want to know what backend is used for a particular interface, you can ask netplan, and parse the output to get the information you need:
netplan generate --mapping enp3s0
It outputs text like this:
id=enp3s0, backend=NetworkManager, set_name=(null), match_name=enp3s0, match_mac=(null), match_driver=(null)
That way you can also know using what matching rules the interface was configured (you use the "final" name of an interface to check the mapping, it tells you what matching rule is in the netplan YAML that matches for it).
You may be able to check for the ifstate file from ifupdown, which will tell you whether that's what was used to configure the network:
/run/network/ifstate
If that's there and it contains text, you can expect that ifupdown is in use. If it's not present, the system is likely managed via netplan (but that won't tell you whether it's NetworkManager or systemd)
Then, if you want to know what backend is used for a particular interface, you can ask netplan, and parse the output to get the information you need:
netplan generate --mapping enp3s0
It outputs text like this:
id=enp3s0, backend=NetworkManager, set_name=(null), match_name=enp3s0, match_mac=(null), match_driver=(null)
That way you can also know using what matching rules the interface was configured (you use the "final" name of an interface to check the mapping, it tells you what matching rule is in the netplan YAML that matches for it).
answered May 10 at 20:39
![](https://lh5.googleusercontent.com/-fiRcLVS9GpQ/AAAAAAAAAAI/AAAAAAAAFDI/jWTZFSFi_Qs/photo.jpg?sz=32)
![](https://lh5.googleusercontent.com/-fiRcLVS9GpQ/AAAAAAAAAAI/AAAAAAAAFDI/jWTZFSFi_Qs/photo.jpg?sz=32)
Mathieu Trudel-Lapierre
1,9921130
1,9921130
Thank you for your thorough reply. I am now looking for /run/network/ifstate to ascertain what network config to write, and everything seems to work well :)
â Arni J
May 13 at 19:49
add a comment |Â
Thank you for your thorough reply. I am now looking for /run/network/ifstate to ascertain what network config to write, and everything seems to work well :)
â Arni J
May 13 at 19:49
Thank you for your thorough reply. I am now looking for /run/network/ifstate to ascertain what network config to write, and everything seems to work well :)
â Arni J
May 13 at 19:49
Thank you for your thorough reply. I am now looking for /run/network/ifstate to ascertain what network config to write, and everything seems to work well :)
â Arni J
May 13 at 19:49
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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%2faskubuntu.com%2fquestions%2f1033592%2fdetecting-whether-netplan-is-managing-network-config-shell%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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