Skip to main content

Configuración

Cambio de nombre

El comando hostnamectl nos aporta mucha información

$ hostnamectl
 Static hostname: debian
       Icon name: computer-vm
         Chassis: vm 🖴
      Machine ID: 165311023ef044878bc7810849e72380
         Boot ID: 9c313f368c664173ab1c8ec5d4a3b405
  Virtualization: kvm
Operating System: Debian GNU/Linux 12 (bookworm)
          Kernel: Linux 6.1.0-31-amd64
    Architecture: x86-64
 Hardware Vendor: QEMU
  Hardware Model: Standard PC _i440FX + PIIX, 1996_
Firmware Version: rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org
sudo hostnamectl set-hostname "new-name"
echo "new-name" | sudo tee /etc/hostname

Dirección IP estática

La configuración de las interfaces de red está guardada en el archivo /etc/network/interfaces:

/etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
# allow-hotplug eth0
# iface eth0 inet dhcp

# Static IP address
auto eth0
iface eth0 inet static
        address 192.168.1.100
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1

También es necesario indicar la dirección del servidor DNS. En esta configuración, el servidor DNS funciona en el router/modem ADSL, por lo que el parámetro para nameserver debe tener el valor 192.168.1.1, en el archivo/etc/resolv.conf:

/etc/resolv.conf
domain localdomain
search localdomain
nameserver 192.168.1.1

Ahora debe reiniciarse la interfaz de red para activar la nueva configuración:

root@server:~# ifdown eth0
root@server:~# ifup eth0