Sunteți pe pagina 1din 5

#!

/bin/sh #establecer una ip if [ echo echo exit fi if [ echo echo exit fi if [ echo echo exit fi if [ echo echo exit fi ! $1 ]; then "Uso: ./configurar_ip_estatica INTERFAZ IP PUERTA DNS" "INTERFAZ no vlida" 1 ! $2 ]; then "Uso: ./configurar_ip_estatica INTERFAZ IP PUERTA DNS" "IP no vlida" 1 ! $3 ]; then "Uso: ./configurar_ip_estatica INTERFAZ IP PUERTA DNS" "PUERTA de enlace no vlida" 1 ! $4 ]; then "Uso: ./configurar_ip_estatica INTERFAZ IP PUERTA DNS" "DNS no vlido" 1

ifconfig $1 $2 route add default gw $3 echo "nameserver $4" > /etc/resolv.conf echo "---------------------------" echo "Datos actuales de la interfaz:" echo "" ifconfig $1 echo "---------------------------" echo "Datos de las rutas por defecto (puertas de enlace)" echo "" route | grep default echo "---------------------------" echo "Comprobando si hay ping a la puerta de enlace..." echo "" ping -c 5 $3 echo "---------------------------" echo "Comprobando si hay ping a internet..." echo "" ping -c 5 www.google.es

#!/bin/sh echo Bienvenido al configurador de redes: echo Introduzca el nombre del dispositivo a configurar: read wired ifconfig $wired down echo Introduzca ip: read ip echo Introduzca mscara de subred: read mask echo Introduzca direccin broadcast: read broad echo Introduzca puerta de enlace: read gate echo Introduzca DNS: read DNS if [ echo echo exit fi if [ echo echo exit fi if [ echo echo exit fi if [ echo echo exit fi if [ echo echo exit fi if [ echo echo exit fi ! $wired ]; then "Uso: ./configurar_ip_estatica INTERFAZ IP PUERTA DNS" "INTERFAZ no vlida" 1 ! $ip ]; then "Uso: ./configurar_ip_estatica INTERFAZ IP PUERTA DNS" "IP no vlida" 1 ! $mask ]; then "Uso: ./configurar_ip_estatica INTERFAZ IP PUERTA DNS" "MSCARA DE SUBRED no vlida" 1 ! $broad ]; then "Uso: ./configurar_ip_estatica INTERFAZ IP PUERTA DNS" "BROADCAST no vlida" 1 ! $gate ]; then "Uso: ./configurar_ip_estatica INTERFAZ IP PUERTA DNS" "PUERTA de enlace no vlida" 1 ! $DNS ]; then "Uso: ./configurar_ip_estatica INTERFAZ IP PUERTA DNS" "DNS no vlido" 1

ifconfig $wired $ip netmask $mask broadcast $broad route add default gw $gate echo "nameserver $DNS" > /etc/resolv.conf ifconfig $wired up

echo "---------------------------" echo "Datos actuales de la interfaz:" echo "" ifconfig $wired echo "---------------------------" echo "Datos de las rutas por defecto (puertas de enlace)" echo "" route | grep default echo "---------------------------" echo "Comprobando si hay ping a la puerta de enlace..." echo "" ping -c 5 $gate echo "---------------------------" echo "Comprobando si hay ping a internet..." echo "" ping -c 5 www.google.es

El script que yo he realizado para comprobar si la red esta configurada de forma estatica o dinamica es el siguiente: Cdigo

#!/bin/bash tipo=$(cat /etc/netware/interfaces | grep '^iface eth0' | cut -d " " -f 4) if [ $tipo="static" ] then echo 'Conexion estatica' else echo 'Conexion dinamica' fi

Script para configurar Interfases de red,realizar pruebas y asociar a red Wireless El siguiente script esta enfocado en usuarios de Linux los cuales no tienen la experiencia necesaria para la configuracin de interfases de red mediante linea de comandos. Agradece a ustedes enviar comentarios con el fin de mejor o agregar nuevas funciones a este codigo, tambien pueden encontrarlo con otro formato enhttp://www.iwconfig.cl/smf/index.php?topic=15.0 Como hacerlo funcionar Lo primero es abrir una consola y ejecutar Cdigo: $ sudo nano utilitarios_red

Con esto ejecutamos el editor nano creando un archivo llamado utilitarios_red en el cual pegamos lo siguiente clear echo "" echo "" echo "****************************************************************" echo "** Script para configurar Interfases de red,realizar pruebas **" echo "** y asociar a red Wireless. **" echo "****************************************************************" echo " Por Vejeta18 elopez@iwconfig.cl -------- versin 1.0 " echo " Cdigo libre y disponible en http://www.iwconfig.cl " echo " http://www.iwconfig.cl/smf/index.php?topic=15.0 " echo "" echo " Opciones : " # libre de modificacion select opcion in "Configurar_IP" "Asociar_a_router_Wireless" "Buscar_DHCP" "Probar_Conexion_PING" "Salir" do if [ $opcion = "Configurar_IP" ] then ifconfig echo -n "Coloca el nombre de tu interfas de red a configurar (eth0,eth1,etc): " read interfas echo -n "Coloca la ip que quieres asignar a $interfas : " read ip echo -n "Coloca la mascara de red para $interfas : " read mascara echo -n "Coloca la puerta de enlace para $interfas: " read enlace ifconfig $interfas $ip netmask $mascara | route add defaul gw $enlace | ifconfig $interfas up | route;./utilitarios_red elif [ $opcion = "Asociar_a_router_Wireless" ] then echo -n "Pon el nombre de tu interfas Wireless (eth0,eth1,etc) : " read interfas echo -n "Pon el nombre del Router a Asociar: " read ap ifconfig $interfas up | iwconfig $interfas mode manager essid $ap | iwconfig $interfas elif [ $opcion = "Salir" ] then exit echo -n "Pon el nombre de tu interfas Wireless (eth0,eth1,etc) : " read interfas echo -n "Pon el nombre del Router a Asociar: "

read ap ifconfig $interfas up | iwconfig $interfas mode manager essid $ap | iwconfig $interfas elif [ $opcion = "Buscar_DHCP" ] then echo -n "Ingresa la Interfas para buscar ip mediante DHCP (eth0,eth1,etc): " read interfas dhclient $interfas;./utilitarios_red elif [ $opcion = "Probar_Conexion_PING" ] then echo -n " Coloca una direccion para probar conexion (www.google.cl,loclhost, etc.. : " read direccion ping -c 5 $direccion;./utilitarios_red break fi done

S-ar putea să vă placă și