================== Network ================== Basic command line tools ============================= * Get the list of the interfaces .. prompt:: bash nmcli dev status Output of the command : .. prompt:: bash $ auto $ nmcli dev status DEVICE TYPE STATE CONNECTION enp0s31f6 ethernet connected Wired connection 1 enp3s0 ethernet connected TOF sensor 1 wlp9s0 wifi disconnected -- enp10s0 ethernet unavailable -- enp4s0 ethernet unavailable -- enp7s0 ethernet unavailable -- enp8s0 ethernet unavailable -- lo loopback unmanaged -- * Get all the current interfaces configuration .. prompt:: bash ifconfig * View the network routes .. prompt:: bash ip route # All routes ip route | grep default # Default gw * Set up an interface .. prompt:: bash nmtui # run the NMTUI (Network Manager Text User Interface) and follow the steps on the screen .. warning:: Do NOT use *ifconfig* to set up an interface, it is deprecated and does not always work (typically on our Spectra 1-2 with Ubuntu 18.04 ) * Set up the default gateway .. code-block:: bash # Using route command $ sudo route add default gw # Using ip command $ sudo ip route add default via Limitation of the ephemeral ports range =============================================== An ephemeral port is a short-lived port used by a program to communicate via an internet protocol to another program. It is allocated automatically from a predefined range. The configuration file is located in ``/proc/sys/net/ipv4/ip_local_port_range``. It is not possible to modify it with a text editor. * Modify the range of ephemeral ports .. prompt:: bash sudo sysctl -w net.ipv4.ip_local_port_range="58000 60999" .. note:: It seems like it will be reset to original values after a reboot. Advanced network configuration file ========================================== Located in */etc/netplan/* is a YAML file (often called *config.yaml*) that describes the network settings. It can be modified. * The standard version means that the GUI is responsible for the settings To visualize it, run : .. prompt:: bash cat /etc/netplan/*.yaml The output should be : .. code-block:: yaml network: version: 2 renderer: NetworkManager * To ensure the PC will follow a specified network configuration, it is possible to define for each interface its configuration. The content of the *config.yaml* file could for example looks like the following configuration : .. code-block:: yaml network: version: 2 renderer: networkd # Static IP address for all Ethernet interfaces, with 255.255.255.0 as mask ethernets: enp3s0: addresses: - 192.168.0.100/24 dhcp4: false enp4s0: addresses: - 192.168.1.100/24 dhcp4: false enp7s0: addresses: - 192.168.2.100/24 dhcp4: false enp8s0: addresses: - 192.168.3.100/24 dhcp4: false # Connection to a secured WPA Enterprise Wifi wifis: wlp9s0: access-points: workplace: auth: key-management: eap method: peap identity: "login" password: "pw" dhcp4: true More examples about netplan can be found on `netplan.io/examples `_. * After modifying the YAML file, the following command must be run : .. prompt:: bash sudo netplan apply :tag:`Linux` :tag:`Network`