Suitable for CENTOS7
[Email protected]_1 ~]# Cat yum_ip.sh
#!/bin/bash
# is used to CentOS 7
Mv/etc/sysconfig/network-scripts/ifcfg-eno16777728{,.bak}
Cat >/etc/sysconfig/network-scripts/ifcfg-eno16777728 << EOF
Type=ethernet
Bootproto=none
Nm_controlled=no
Defroute=yes
Peerdns=yes
Peerroutes=yes
Ipv4_failure_fatal=yes
Ipv6init=no
Ipv6_autoconf=no
Ipv6_defroute=no
Ipv6_peerdns=no
Ipv6_peerroutes=no
Ipv6_failure_fatal=no
name=eno16777728
uuid=76f9cf7b-5390-44da-af35-16fdf334f81f
device=eno16777728
Onboot=yes
ipaddr=192.168.1.200
netmask=255.255.255.0
gateway=192.168.1.1
dns=202.106.0.20
Eof
Cat >/etc/resolv.conf << EOF
NameServer 202.106.0.20
Eof
For i in ' ls/etc/yum.repos.d/'
Do
mv/etc/yum.repos.d/$i {,. bak}
Done
Cat >/etc/yum.repos.d/aliyun.repo << EOF
[Aliyun]
Name=ali
baseurl=http://mirrors.aliyun.com/centos/7/os/x86_64/
Gpgcheck=0
Enabled=1
[Epel]
Name=epel
baseurl=http://mirrors.aliyun.com/epel/7/x86_64/
Gpgcheck=0
Enabled=1
Eof
/etc/init.d/network restart
This article is from the "Linux" blog, so be sure to keep this source http://ridingonhorse.blog.51cto.com/11265295/1872812
Installed _yum&ip