-
Notifications
You must be signed in to change notification settings - Fork 2
/
static_ip
20 lines (15 loc) · 651 Bytes
/
static_ip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
# Pedir la IP y la máscara al usuario
read -p "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Introduce la dirección IP: " IP
read -p "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)Introduce la máscara de red: " MASK
# Configurar la IP estática en el archivo /etc/network/interfaces
cat << EOF > /etc/network/interfaces
auto eth0
iface eth0 inet static
address $IP
netmask $MASK
EOF
# Reiniciar el servicio de red para aplicar los cambios
systemctl restart networking.service
echo "$(tput setaf 1)[$(tput setaf 3)*$(tput setaf 1)]$(tput setaf 6)La dirección IP se ha configurado a $IP"
tput sgr0