标签:用户登录 sysconfig can type init name ipa npe 修改
一: 修改网卡配置文件(操作前先备份一下该文件),/etc/sysconfig/network-scripts/
具体操作如下:
1:进入修改目录
1 [root@localhost ~]# clear # 1: root 用户登录 并清理屏幕 2 [root@localhost ~]# cd /etc/sysconfig/network-scripts/ #2:进入 设置ip 信息的 /etc/sysconfig/network-scripts/ 目录下 3 [root@localhost network-scripts]# ls #3 查看该目录下的文件信息 4ifcfg-ens33 ifdown-ipv6 ifdown-TeamPort ifup-ippp ifup-routes network-functions 5 ifcfg-lo ifdown-isdn ifdown-tunnel ifup-ipv6 ifup-sit network-functions-ipv6 6 ifdown ifdown-post ifup ifup-isdn ifup-Team 7 ifdown-bnep ifdown-ppp ifup-aliases ifup-plip ifup-TeamPort 8 ifdown-eth ifdown-routes ifup-bnep ifup-plusb ifup-tunnel 9 ifdown-ib ifdown-sit ifup-eth ifup-post ifup-wireless 10 ifdown-ippp ifdown-Team ifup-ib ifup-ppp init.ipv6-global 11
2:查看 网卡 ifcfg-ens33 (网卡:每个机器的网卡名称都不相同)
1 [root@localhost network-scripts]# cat ifcfg-ens33 2 TYPE="Ethernet" 3 BOOTPROTO="dhcp" 4 DEFROUTE="yes" 5 PEERDNS="yes" 6 PEERROUTES="yes" 7 IPV4_FAILURE_FATAL="no" 8 IPV6INIT="yes" 9 IPV6_AUTOCONF="yes" 10 IPV6_DEFROUTE="yes" 11 IPV6_PEERDNS="yes" 12 IPV6_PEERROUTES="yes" 13 IPV6_FAILURE_FATAL="no" 14 IPV6_ADDR_GEN_MODE="stable-privacy" 15 NAME="ens33" 16 UUID="59469ff2-89aa-4cb0-9304-bb1ca20c9db3" 17 DEVICE="ens33" 18 ONBOOT="yes" 19
3:备份 网卡 ifcfg-ens33 信息
1 [root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens33_bak_20170827 2
4:编辑 网卡网卡 ifcfg-ens33 信息
默认该文件中还有其他配置,可以都删除或注释。
1 [root@localhost network-scripts]# vi ifcfg-ens33 2 [root@localhost network-scripts]# cat ifcfg-ens33 3 TYPE="Ethernet" 4 BOOTPROTO="static" 5 IPADDR=192.168.1.21 6 NETMASK=255.255.255.0 7 NETWORK=192.168.1.1 8 NAME="ens33" 9 ME="ens33" 10 ONBOOT="yes" 11 DNS1=192.168.1.1 12 13 14 #DEFROUTE="yes" 15 #PEERDNS="yes" 16 #PEERROUTES="yes" 17 #IPV4_FAILURE_FATAL="no" 18 #IPV6INIT="yes" 19 #IPV6_AUTOCONF="yes" 20 #IPV6_DEFROUTE="yes" 21 #IPV6_PEERDNS="yes" 22 #IPV6_PEERROUTES="yes" 23 #IPV6_FAILURE_FATAL="no" 24 #IPV6_ADDR_GEN_MODE="stable-privacy" 25 #NAME="ens33" 26 #UUID="59469ff2-89aa-4cb0-9304-bb1ca20c9db3" 27 #DEVICE="ens33" 28 #ONBOOT="yes" 29
二:修改网关配置文件,/etc/sysconfig/network 信息 ,如下:
1:切换目录,查看文件信息
1 [root@localhost network-scripts]# cd .. 2 [root@localhost sysconfig]# ls 3 atd cgred ebtables-config init iptables-config kernel man-db network-scripts pluto rdisc rsyncd saslauthd svnserve virtlogd 4 authconfig console fcoe ip6tables iptables.rpmnew ksm modules nfs qemu-ga readonly-root rsyslog selinux sysstat wpa_supplicant 5 autofs cpupower firewalld ip6tables-config irqbalance libvirtd netconsole ntpd radvd rpcbind run-parts smartmontools sysstat.ioconf 6 cbq crond grub iptables kdump libvirt-guests network ntpdate raid-check rpc-rquotad samba sshd virtlockd 7 [root@localhost sysconfig]# pwd 8 /etc/sysconfig 9 [root@localhost sysconfig]# cat network 10 # Created by anaconda 11
2:修改 network 文件信息
1 [root@localhost sysconfig]# vi network 2 [root@localhost sysconfig]# cat network 3 # Created by anaconda 4 5 NETWORKING=yes 6 NETWORKING_IPV6=no 7 HOSTNAME=localhost.localdomain 8 GATEWAY=192.168.1.1 9 10
3:重启服务:
1 [root@localhost sysconfig]# systemctl restart network 2
测试:
服务重启之后的ip信息
原ip地址登录不了了
注:本文参考了cnblogs:oslivan的《Centos7下面配置静态IP》文章
标签:用户登录 sysconfig can type init name ipa npe 修改
原文地址:http://www.cnblogs.com/ios9/p/Centos7_staticIp_update.html