0

I'm using two boards, one running ubuntu desktop 18.04 and one running ubuntu server 18.04. In the desktop board, I have set a vlan by writing the /etc/network/interfaces file as described below (I know it is incorrect to set auto by first and than set a static address, but it is working anyhow and it is not the topic of my question):

auto eno1

iface eno1 inet dhcp

auto eno1.1

iface eno1.1 inet static

 address XX.XX.XX.91/23

 netmask 255.255.254.0

 gateway XX.XX.XX.1

 vlan-raw-device eno1


auto lo

iface lo inet loopback

I need to do just the same setting: two addresses on a unique physical port using vlan, naming like eno1 and eno1.1, with only eno1.1 defined as a static address, for the board where ubuntu server is loaded. I have seen the /etc/network/interface is not used at all and the networks must be set using /etc/netplan/50-cloud-init.yaml. I wasn't able to have a working board just following netplan.io/examples for vlan setting. So I would appreciate if you could help me showing how NN-cloud-init.yaml should look like to do just the same as in my /etc/network/interfaces file for the desktop.

  • Is it ONE physical ethernet port... with ONE or TWO MAC addresses? Edit your question with the .yaml file that you've tried, and how much worked or didn't work. Also sudo lshw -C network. – heynnema Apr 4 at 16:39
  • it is one physical ethernet port and we are talking about vlan setting. No reason to post a .yaml file that doesn't work at all and still the question is, for me, pretty clear: vlan setting using traditional interfaces file works and I'd like to see how it should look like the SAME setting using netplan. Thanks – CarloV Apr 5 at 7:04
0

Try this skeleton. Some tweaking may be required. Fill out the appropriate MAC, IP's, and DNS. Keep the indentation, spacing, and no tabs.

network:
  version: 2
  renderer: networkd
  ethernets:
    mainif:
      match:
        macaddress: xx:xx:xx:xx:xx:xx
      set-name: mainif
      dhcp4: false
      dhcp6: false
      optional: true
  vlans: 
    en01: 
      id: 01
      link: mainif
      dhcp4: true
      dhcp6: false
    en01.1:
      id: 11
      link: mainif
      addresses: XX.XX.XX.91/23
      gateway4: XX.XX.XX.1
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]
        search: [ domain1.example.com, domain2.example.com ]

sudo netplan --debug generate # generate config files

sudo netplan apply # apply configuration

reboot # verify proper operation

  • Hi, please, refer to askubuntu.com/questions/990825/virtual-interface-in-netplan: I have removed the *.yaml file as suggested in that question to have the network working as I'd like (and installed the ifupdown). So, if I understood it right, there is a bug and it is not possible to set the vlan using netplan. Thanks for your contribution, very appreciated – CarloV Apr 5 at 13:08
  • @CarloV Have I just wasted my time? If you thought there was a potential problem, you might have articulated that in your original question. The problem described in your link is over 1 year old. If you're going to use ifupdown then you might as well use renderer: NetworkManager in a .yaml file. Please try my .yaml and confirm for yourself that it won't work with the latest version of netplan. Report back. – heynnema Apr 5 at 13:18
  • @CarloV status please... – heynnema Apr 5 at 19:59
  • Hi Heynnema, sorry for delay answering your comment, but I didn't get access to the mails during the weekend. I split my comment here, due to limited numbers of characters in the comments. – CarloV Apr 8 at 6:49
0

I have tried to rewrite your skeleton to provide the setting I needed. the 50-cloud-init.yaml file looks like below:

network:
version: 2
renderer: networkd
  ethernets:
    eno1:
      dhcp4: true
  vlan:
    eno1.1:
      id: 1
      link: eno1
      addresses: [XX.YY.ZZ.91/23]

that file generate devices just as I need, with an issue: the board remains isolated. From the board, I can ping localhost, eno1 and eno1.1, but not another board in the network and, by all means, another board in the network cannot ping that one. At that time I decided to use ifupdown as a shortcut for my problem, but maybe there is really nothing wrong in the 50-cloud-init.yaml. my speculation is that the packets are (most likely in a correct behavior) dropped because missing of a VLAN tag. In order to let the board to communicate to the externel world, I should probably change the 50-cloud-init.yaml as following:

network:
version: 2
renderer: networkd
  ethernets:
    eno1:
      dhcp4: true
  vlan:
    eno1.1:
      accept-ra: true
      id: 1
      link: eno1
      addresses: [XX.YY.ZZ.91/23]

I guess that would work. Unluckily, I cannot remove the installed ifupdown, so I cannot be sure 100% about my speculation.

One more info to complete the picture: even if you are using ifupdown, the standard 50-cloud-init.yaml must not be deleted. In fact, if you delete the standard 50-cloud-init.yaml, that looks like:

network:
  ethernets:
    eno1:
      dhcp4: true
version: 2

the dhcp4 would change the IP address assigned dynamically to the board.

One more time, let me thank you for your time and valuable support and again sorry for the late answer.

BR/Carlo

  • I formatted your code segments. Three issues. 1) "vlan:" should be "vlans:", 2) you may wish to re-add "optional: true" so that there's no 2 minute boot delay waiting for the network to come up, 3) .yaml is very fussy about indentation, spacing, no tabs, and no extra spaces/lines. – heynnema Apr 8 at 7:48
  • What about gateway4: and nameservers: for en01.1? – heynnema Apr 8 at 7:56
  • Hi Heynnema, I have accepted your answer. As far as I remember, gateway and nameservers setting didn't make any difference in the result, but, as mentioned already, i cannot run other test in my environment right now. Thanks! BR/Carlo – CarloV Apr 8 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.