How to use Netplan Network and Configuration on Ubuntu

 

What is Netplan?

The network utility is a release for the new version of the ubuntu platform instead of the old network utility. Because of this change, It easy to use, deploy and don't need to reboot system. 

How does it work?

If you want to config network first you need to permission as administrator and you should go to  /etc/netplan/*.yaml path. The Installers, cloud image instantiations, or other OS deployments. During the early boot, Netplan generated backend configuration file in /run to hand off control of devices to a particular networking daemon.

If you need to know more detail please check link bellow:



How can I use it?

    Configuration    

        To configure netplan, save configuration files under /etc/netplan/ with a .yaml extension (e.g. /etc/netplan/config.yaml), then run sudo netplan apply. This command parses and applies the configuration to the system. Configuration written to disk under /etc/netplan/ will persist between reboots.


network:
    version: 2
    renderer: NetworkManager


    Commands Line

    Three subcommands to drive its behavior:
  •     netplan generate: /etc/netplan to generate the required configuration for the renderers.
  •     netplan apply: Apply all configuration for the renderers, restarting them as necessary. 
  •     netplan try: Apply configuration and wait for user confirmation; will roll back if network is broken or no confirmation is given.

    How to configure Netplan as DHCP

To let the interface named ‘enp3s0’ get an address via DHCP, create a YAML file with the following:

network:
    version: 2
    renderer: networkd
    ethernets:
        enp3s0:
            dhcp4: true


   How to configure Netplan as​ Static

    To instead set a static IP address, use the addresses key, which takes a list of (IPv4 or IPv6), addresses along with the subnet prefix length (e.g. /24). DNS information can be provided as well, and the gateway can be defined via a default route:

 network:

    version: 2

    renderer: networkd

    ethernets:

        enp3s0:

            addresses:

                - 10.10.10.2/24

            nameservers:

                search: [mydomain, otherdomain]

                addresses: [10.10.10.1, 1.1.1.1]

            routes:

                - to: default

                  via: 10.10.10.1


     

      How to configure Netplan as​ DHCP with multiple interface


network:
    version: 2
    ethernets:
        enred:
            dhcp4: yes
            dhcp4-overrides:
                route-metric: 100
        engreen:
            dhcp4: yes
            dhcp4-overrides:
                route-metric: 200


 

      How to configure Netplan with an open wireless network

        
etwork:
    version: 2
    wifis:
        wl0:
            access-points:
                opennetwork: {}
            dhcp4: yes

      How to configure Netplan with a WPA Personal wireless network

network:
    version: 2
    renderer: networkd
    wifis:
        wlp2s0b1:
            dhcp4: no
            dhcp6: no
            addresses: [192.168.0.21/24]
            nameservers:
                addresses: [192.168.0.1, 8.8.8.8]
            access-points:
                "network_ssid_name":
                    password: "**********"
            routes:
                - to: default
                  via: 192.168.0.1


      How to configure Netplan with a WPA Enterprise wireless networks 

network:
    version: 2
    wifis:
        wl0:
            access-points:
                workplace:
                    auth:
                        key-management: eap
                        method: ttls
                        anonymous-identity: "@internal.example.com"
                        identity: "joe@internal.example.com"
                        password: "v3ryS3kr1t"
            dhcp4: yes


Or, if the network is secured using WPA-EAP and TLS:


network:

    version: 2

    wifis:

        wl0:

            access-points:

                university:

                    auth:

                        key-management: eap

                        method: tls

                        anonymous-identity: "@cust.example.com"

                        identity: "cert-joe@cust.example.com"

                        ca-certificate: /etc/ssl/cust-cacrt.pem

                        client-certificate: /etc/ssl/cust-crt.pem

                        client-key: /etc/ssl/cust-key.pem

                        client-key-password: "d3cryptPr1v4t3K3y"

            dhcp4: yes

     It have different mode of encryption are supported. see the Netplan reference more detail


      How to configure Netplan with multiple address on a single interface

network:
    version: 2
    renderer: networkd
    ethernets:
        enp3s0:
         addresses:
             - 10.100.1.38/24
             - 10.100.1.39/24
         routes:
             - to: default
               via: 10.100.1.1


      How to configure Netplan with multiple address and multiple gateways

network:
    version: 2
    renderer: networkd
    ethernets:
        enp3s0:
         addresses:
            - 10.0.0.10/24
            - 11.0.0.11/24
            routes:
            - to: default
              via: 10.0.0.1
              metric: 200
            - to: default
              via: 11.0.0.1
              metric: 300

as we known default route or 0.0.0.0/0 using the address of the gateway for the subnet. 

Previous Post Next Post

نموذج الاتصال