首页 > 代码库 > Network_config.sh

Network_config.sh

#!/bin/bash 

service iptables stop
chkconfig iptables off

sed -i ‘/SELINUX=enforcing/s/^/#/‘ /etc/selinux/config
sed -i ‘/#SELINUX=enforcing/a SELinux=disabled‘ /etc/selinux/config 

cp /etc/sysconfig/network /etc/sysconfig/network.bak
rm /etc/sysconfig/network
cat >> /etc/sysconfig/network << "EOF"
NETWORKING=yes
HOSTNAME=oracle11g.local
#开启NTP客户端时启用
#NTPSERVERARGS=iburst
GATEWAY=192.168.1.1
EOF

echo "192.168.1.128 oracle11g oracle11g.local" >> /etc/hosts 

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.bak
rm  /etc/sysconfig/network-scripts/ifcfg-eth0
sed -n ‘/HWADDR=/p‘ /etc/sysconfig/network-scripts/ifcfg-eth0.bak >> /etc/sysconfig/network-scripts/ifcfg-eth0
sed -n ‘/UUID=/p‘ /etc/sysconfig/network-scripts/ifcfg-eth0.bak >> /etc/sysconfig/network-scripts/ifcfg-eth0

cat >> /etc/sysconfig/network-scripts/ifcfg-eth0 << "EOF"
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.1.128
PREFIX=24
GATEWAY=192.168.1.1
DNS1=192.168.1.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
EOF

sed -i ‘/Red Hat Enterprise Linux Server release 6.5 (Santiago)/s/^/#/‘ /etc/redhat-release
sed -i ‘a Red Hat Enterprise Linux Server release 5.0 (Tikanga)‘ /etc/redhat-release



Network_config.sh