-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from DanieelJP/patch-11
Create slapd4_client.sh
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# Verificar si se pasaron los argumentos necesarios | ||
if [ "$#" -ne 3 ]; then | ||
echo "Uso: $0 <interfaz> <nueva_ip> <mascara>" | ||
echo "Ejemplo: $0 enp3s0 192.168.12.200/24" | ||
exit 1 | ||
fi | ||
|
||
# Asignar los argumentos a variables | ||
INTERFAZ=$1 | ||
NUEVA_IP=$2 | ||
MASCARA=$3 | ||
|
||
# Eliminar la IP actual (asumimos que hay una sola) | ||
sudo ip addr flush dev $INTERFAZ | ||
|
||
# Asignar la nueva IP con la máscara especificada | ||
sudo ip addr add $NUEVA_IP/$MASCARA dev $INTERFAZ | ||
|
||
# Subir la interfaz para aplicar los cambios | ||
sudo ip link set dev $INTERFAZ up | ||
|
||
# Mostrar la configuración de la interfaz | ||
ip addr show dev $INTERFAZ | ||
|
||
echo "La nueva IP $NUEVA_IP/$MASCARA ha sido asignada a la interfaz $INTERFAZ." |