Last active
August 26, 2019 13:55
-
-
Save cerealskill/eecb0b3114eeee3e29dffb6698147136 to your computer and use it in GitHub Desktop.
Manual Bash Script for Configure Network Interfaz (Support CentOS 6 o 7)
This file contains hidden or 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
#!/bin/bash | |
# @octopusgen - 08-04-2017 | |
# add dns servers | |
echo "nameserver 10.30.1.12" > /etc/resolv.conf | |
echo "nameserver 10.30.1.14" >> /etc/resolv.conf | |
# add network for ethX | |
ETH="eth1"; | |
MAC="00:50:56:A1:31:C9"; | |
IP="10.30.3.181"; | |
HOST="paine2017"; | |
GW="10.30.1.1"; | |
# Create the Script ifcfg-XX | |
PATH_NETCONFIG="/etc/sysconfig/network-scripts/ifcfg-$ETH"; | |
echo "DEVICE=$ETH" > $PATH_NETCONFIG; | |
echo "NM_CONTROLLED='yes' " >> $PATH_NETCONFIG | |
echo "ONBOOT=yes" >> $PATH_NETCONFIG | |
echo "HWADDR=$MAC" >> $PATH_NETCONFIG | |
echo "TYPE=Ethernet" >> $PATH_NETCONFIG | |
echo "BOOTPROTO=static" >> $PATH_NETCONFIG | |
echo "NAME='System $ETH'" >> $PATH_NETCONFIG | |
echo "UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03" >> $PATH_NETCONFIG | |
echo "IPADDR=$IP" >> $PATH_NETCONFIG | |
echo "NETMASK=255.255.0.0" >> $PATH_NETCONFIG | |
# Setting the gateway | |
PATH_NETWORK="/etc/sysconfig/network"; | |
echo "NETWORKING=yes" > $PATH_NETWORK; | |
echo "HOSTNAME=$HOST" >> $PATH_NETWORK; | |
echo "GATEWAY=$GW" >> $PATH_NETWORK; | |
# /etc/hosts | |
echo "127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4" > /etc/hosts | |
echo "::1 localhost localhost.localdomain localhost6 localhost6.localdomain6" >> /etc/hosts | |
echo "$IP $HOST" >> /etc/hosts | |
# restart the network services | |
/etc/init.d/network restart | |
# install package for sysadmin | |
yum install -y vim nano telnet screen nmap openssh-clients wget rsync git net-tools traceroute bind-utils | |
# recommend reboot the system | |
# reboot | |
Herramientas Esenciales para la administración de servicios
sudo yum install -y vim nano telnet screen nmap openssh-clients wget rsync git net-tools traceroute bind-utils
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Script para generar configuración automática de la interfaz de red modo "Manual" . Para CentOS 6.7 o 7.
El script principalmente realiza las siguientes acciones
Se agregan los servidores DNS
Se crea script de configuración de la tarjeta de red en modo "manual" utilizando TCP/IP estática.
Se agrega puerta de enlace (por defecto)
Se crea tabla hosts (base)
Reiniciamos el servicio de networking
Instalamos algunos paquetes adicionales para facilitar la administración (Go Sysadmin ;)).