• UBUNTU > les adresses IP

      ADRESSE IP STATIQUE

      via le routeur

      --

      via netplan

      La configuration se fait à travers de fichiers .yaml se trouvant dans /etc/netplan/

      Netplan supporte deux renderers : NetworkManager (Ordi de bureau) et Systemd-networkd (serveurs sans GUI).

      Configuring Static IP address on Ubuntu Server

      Les interfaces (Predictable Network Interface Names) commencent par en[lettre][nombre].

       

      Voir la liste de commandes ip link :

       

      ip link
      1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
      3: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
          link/ether 56:00:00:60:20:0a brd ff:ff:ff:ff:ff:ff

       

      Voyons voir avec 01-netcfg.yaml, 50-cloud-init.yaml ou NN_interfaceName.yaml :

       

      sudo vim /etc/netplan/01-netcfg.yaml
      network:
          version: 2
          renderer: networkd
          ethernets:
            ens3:
              dhcp4: yes

       

      Chaque fichier commence par network key that has at least two required elements.

      - 1) Version du network configuration format

      - 2) Le type de matériel : ethernets, bonds, bridges, et vlans.

      renderer:networkd (pour les serveeurs)

      Under the device’s type ( ethernets) we can specify one or more network interfaces. In this example we have only one interface ens3 that is configured to obtain IP addressing from a DHCP server dhcp4: yes.

       

      To assign a static IP address to ens3 interface edit the file as follows:

       

      - Specify the static IP address 192.168.121.199/24. Under addresses: you can add one or more IPv4 or IPv6 IP addresses that will be assigned to the network interface.

      - Specify the gateway gateway4: 192.168.121.1

      - Under nameservers, specify the nameservers addresses: [8.8.8.8, 1.1.1.1]

       

      network:
        version: 2
        renderer: networkd
        ethernets:
          ens3:
            dhcp4: no
            addresses:
              - 192.168.121.199/24
            gateway4: 192.168.121.1
            nameservers:
                addresses: [8.8.8.8, 1.1.1.1]

       

      Puis on applique la règle:

       

      sudo netplan apply

       

      Et on vérifie :

       

      ip addr show dev ens3
      3: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
          link/ether 56:00:00:60:20:0a brd ff:ff:ff:ff:ff:ff
          inet 192.168.121.199/24 brd 192.168.121.255 scope global dynamic ens3
             valid_lft 3575sec preferred_lft 3575sec
          inet6 fe80::5054:ff:feb0:f500/64 scope link
             valid_lft forever preferred_lft forever

       

      en mode fenêtres

      Setting up a static IP address on Ubuntu Desktop computers requires no technical knowledge.

      1. In the Activities screen, search for “network” and click on the Network icon. This will open the GNOME Network configuration settings. Click on the cog icon.
      2. This will open the Network interface settings dialog box.
      3. In “IPV4” Method” section select “Manual”, and enter your static IP address, Netmask and Gateway. Once done, click on the “Apply” button.

      Now that you have set up a static IP Address, open your terminal either by using the Ctrl+Alt+T keyboard shortcut or by clicking on the terminal icon and verify the changes by typing:

      ip addr

      The output will show the interface IP address:

      ...
      2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
          link/ether 52:54:00:e9:40:f2 brd ff:ff:ff:ff:ff:ff
          inet 192.168.121.106/24 brd 192.168.121.255 scope global dynamic noprefixroute eth0
             valid_lft 3523sec preferred_lft 3523sec
          inet6 fe80::5054:ff:fee9:40f2/64 scope link
             valid_lft forever preferred_lft forever

      --

 

Aucun commentaire

 

Laissez un commentaire