¿Cómo obtener información básica de red con nmcli?

¿Cómo obtener información básica de red con nmcli en GNU/Linux?

El post pretende ser un recordatorio para mi mismo y un acicate para profundizar en nmcli, un desconocido para mi, que me ha parecido más amigable que el nuevo ip.

A modo de ejemplo, listo las conexiones activas con el comando en negrita:


user@machine:~$ nmcli connection show
NAME UUID TYPE DEVICE
MIWIFI_2G_nnGQ 43ce5cc0-6ecc-4fca-997b-ccdcb12ca2ff wifi
wlx74da38e4733c

virbr0 a756e70d-7f44-4bc6-8ce7-a3d1265cee1f bridge virbr0
Conexión cableada 1 3df083b6-e2d3-35b6-a55d-d1c540443eca ethernet

¿Cómo sé a qué velocidad se conecta la WiFi? nmcli ofrece un parámetro para saber los campos (-f para fields en inglés) de las conexiones a las que el sistema puede acceder.

user@machine:~$ nmcli -f WIFI-PROPERTIES dev show wlx74da38e4733c
WIFI-PROPERTIES.WEP: sí
WIFI-PROPERTIES.WPA: sí
WIFI-PROPERTIES.WPA2: sí
WIFI-PROPERTIES.TKIP: sí
WIFI-PROPERTIES.CCMP: sí
WIFI-PROPERTIES.AP: sí
WIFI-PROPERTIES.ADHOC: sí
WIFI-PROPERTIES.2GHZ: sí
WIFI-PROPERTIES.5GHZ: no
WIFI-PROPERTIES.MESH: sí
WIFI-PROPERTIES.IBSS-RSN: sí

Para quedarnos con ganas de explorar más las opciones de nmcli podemos listar la conexión concreta que nuestro equipo utilizaba y filtrar información sobre IPv4. Nos permite ver la ip de la conexión, la del router, los DNS que utiliza, etc.

user@machine:~$ nmcli connection show "MIWIFI_2G_nnGQ" | grep ^IP4
IP4.ADDRESS[1]: 192.168.1.142/24
IP4.GATEWAY: 192.168.1.1
IP4.ROUTE[1]: dst = 0.0.0.0/0, nh = 192.168.1.1, mt = 600
IP4.ROUTE[2]: dst = 169.254.0.0/16, nh = 0.0.0.0, mt = 1000
IP4.ROUTE[3]: dst = 192.168.1.0/24, nh = 0.0.0.0, mt = 600
IP4.DNS[1]: 212.230.135.2
IP4.DNS[2]: 212.230.135.1
IP4.DOMAIN[1]: home

Debian cumple 27 años

Debian cumple 27 años, es la excusa para felicitarles y contar por qué no utilizo Debian como distribución preferente.

Si quieres más información sobre Debian cualquiera sabrá más que yo. Hay un par de cosas que me gustan de Debian.

  • Es un proyecto con base en la comunidad, no en una empresa. Todos podemos ayudar, también las personas no técnicas, por ejemplo traduciendo.
  • Su Contrato Social son unos principios que comparto y han mantenido un compromiso con el Software Libre (aunque van más allá del software).
  • Los recursos de instalación y ejecución que requiere son óptimos, puedes instalarla -además- en casi cualquier cosa que tenga una CPU y funciona.
  • Instalar Debian es una garantía de estabilidad y seguridad si utilizas la versión stable, claro.

¿Por qué elijo otra distribución? Empleo Linux en el trabajo y en el mundo de la empresa es común que los CPD estén desplegados sobre Red Hat Enterprise Linux, su clon CentOS y en los último años ha crecido la implantación de Ubuntu, basada en Debian, por cierto.

Utilizo en mis tareas de laboratorio en casa distribuciones próximas o iguales a las del trabajo, por eso no empleo preferentemente Debian. La máquina que siempre está en marcha en casa (aunque ahora solo tenga un uptime de 24 días), curiosamente sí está basada en Debian.

Es muy recomendable, especialmente si quieres aprender como funciona un sistema Linux por dentro. La implantación en entorno de empresa ha sido lo que me ha apartado de profundizar en Debian, me considero un usuario, no un administrador de Debian y … sí es estupenda.

Minimum securization for sshd

I run an RaspberryPi inside my home network with ssh access allowed. One of the first things I’d done was to install fail2ban package.

I know this is not enough by far. A really secure configuration requires more intel in it but I let it that way just to check how much penetration attemps I’ll see.

After a fast review in the /var/log/fail2ban.log file I notice that almost everything were ssh tries to log in the system. Which is perfectly normal because the system only exposes a web server and the sshd daemon.

An easy and fast securization for your home systems with ssh is to edit the /etc/hosts.allow and the /etc/host deny files to concrete what IP’s are allow to log in via ssh and deny all the rest. You may do the same secure configuration via /etc/ssh/sshd_config what it requieres more ssh knowledge and I prefer dedicate another post to it.

To allow you home network edit your /etc/host.allow and add:
sshd: 192.168.0.0/24 # this allow your local lan
sshd: 127.0.0.1 # this allow your localhost

To deny any other IP edit your /etc/hosts.deny and add:
sshd: ALL

How to install a concrete binary in a rpm distro

How to install a concrete binary in a rpm based distribution? Let’s asume you have a rpm based distro. I will wrote this little howto using a CentOS 7.8.

For instance you need to install iwlist but you don’t know what package provides you that binary. You have to type:


# yum provides iwlist

Your local database will return you something like this:

[pbenavent@localhost ~]$ yum provides iwlist
Complementos cargados:fastestmirror
Determining fastest mirrors
* base: mirror.gadix.com
* epel: fr2.rpmfind.net
* extras: mirror.airenetworks.es
* updates: mirror.gadix.com
1:wireless-tools-29-13.el7.x86_64 : Wireless ethernet configuration tools
Repositorio : @epel
Resultado obtenido desde:
Nombre del archivo : /usr/sbin/iwlist

Now you know the package name that you need to install, so the only thing you need to do is installed:

# yum install wireless-tools

As you may notice by reading the above lines, it’s assumed that your repository have indexed in its information the binary and package you’re querying for. In this particular exemple, the binary was iwlist and in the answer you read the full path indexed (/usr/bin/iwlist) wich is provided by EPEL repos. Remember the EPEL repo it’s not installed by defaul.

Four F’s in the Fedora Project

Fedora is Linux distribution with two pilars: community and Red Hat support. They have choose an easy way to describe the project by focusing on four concepts all beginning with the letter “F”:

  • Freedom: Fedora distro uses free software and free content, done or maintained by them
  • Friends: At Fedora’s page they said something naive about friendship but also “Like any friends, we occasionally disagree on details, but we believe in finding an acceptable consensus to serve the interests of advancing free software.
  • Features: My personal opinion about what features means in Fedora is about they improve the free software ecosystem not only by offering a distro ready for use but also they build new software and offers it to the community, for instance, yum, dnf, cockpit
  • First: This last F in the four F’s are the main difference among Fedora, CentOS or Red Hat Enterprise Linux which is related with the life cicle of Fedora, they release two versions per year at least.