Centos7最小化安装后 配置静态IP 和 主机名
Centos7最小化安装后 配置静态IP 和 主机名
(一)
- [root@master network-scripts]# cd /etc/sysconfig/network-scripts
- [root@master network-scripts]#
- [root@master network-scripts]# dir
- ifcfg-ens160 ifdown-bnep ifdown-ipv6 ifdown-ppp ifdown-Team ifup ifup-eth ifup-isdn ifup-post ifup-sit ifup-tunnel network-functions
- ifcfg-lo ifdown-eth ifdown-isdn ifdown-routes ifdown-TeamPort ifup-aliases ifup-ippp ifup-plip ifup-ppp ifup-Team ifup-wireless network-functions-ipv6
- ifdown ifdown-ippp ifdown-post ifdown-sit ifdown-tunnel ifup-bnep ifup-ipv6 ifup-plusb ifup-routes ifup-TeamPort init.ipv6-global
- [root@master network-scripts]# clear
- [root@master network-scripts]# pwd
- /etc/sysconfig/network-scripts
- [root@master network-scripts]# dir
- ifcfg-ens160 ifdown-bnep ifdown-ipv6 ifdown-ppp ifdown-Team ifup ifup-eth ifup-isdn ifup-post ifup-sit ifup-tunnel network-functions
- ifcfg-lo ifdown-eth ifdown-isdn ifdown-routes ifdown-TeamPort ifup-aliases ifup-ippp ifup-plip ifup-ppp ifup-Team ifup-wireless network-functions-ipv6
- ifdown ifdown-ippp ifdown-post ifdown-sit ifdown-tunnel ifup-bnep ifup-ipv6 ifup-plusb ifup-routes ifup-TeamPort init.ipv6-global
- [root@master network-scripts]# vi ifcfg-ens160
- TYPE=Ethernet
- BOOTPORTO=static
- IPADDR=192.168.1.130
- GATEWAY=192.168.1.1
- NETMASK=255.255.255.0
- PROXY_METHOD=none
- BROWSER_ONLY=no
- #BOOTPROTO=dhcp
- DEFROUTE=yes
- IPV4_FAILURE_FATAL=no
- IPV6INIT=no
- IPV6_AUTOCONF=yes
- IPV6_DEFROUTE=yes
- IPV6_FAILURE_FATAL=no
- IPV6_ADDR_GEN_MODE=stable-privacy
- NAME=ens160
- UUID=4006d0fe-b004-468e-8896-d233229b6d6a
- DEVICE=ens160
- ONBOOT=yes
(二)
- [root@master sysconfig]# cd /etc/sysconfig
- [root@master sysconfig]# pwd
- /etc/sysconfig
- [root@master sysconfig]# dir
- anaconda chronyd crond grub iptables-config kernel netconsole rdisc run-parts wpa_supplicant
- authconfig console ebtables-config init irqbalance man-db network readonly-root selinux
- cbq cpupower firewalld ip6tables-config kdump modules network-scripts rsyslog sshd
- [root@master sysconfig]# vi network
- # Created by anaconda
- NETWORKING=yes
- NETWORKING_IPV6=no
- GATEWAY=192.168.1.1
(三)
- [root@master etc]# vi /etc/resolv.conf
- # Generated by NetworkManager
- nameserver 192.168.1.1
- search bogon
(四)
- [root@master etc]# hostnamectl set-hostname master
- [root@master etc]#
- [root@master etc]# hostname
- master
- [root@master etc]#
(五)
- [root@master etc]# ifconfig
- ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
- inet 192.168.1.130 netmask 255.255.255.0 broadcast 192.168.1.255
- inet6 fe80::20c:29ff:fe47:9119 prefixlen 64 scopeid 0x20<link>
- ether 00:0c:29:47:91:19 txqueuelen 1000 (Ethernet)
- RX packets 1072 bytes 93239 (91.0 KiB)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 614 bytes 96587 (94.3 KiB)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
- inet 127.0.0.1 netmask 255.0.0.0
- inet6 ::1 prefixlen 128 scopeid 0x10<host>
- loop txqueuelen 1 (Local Loopback)
- RX packets 0 bytes 0 (0.0 B)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 0 bytes 0 (0.0 B)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- [root@master etc]# ping www.baidu.com -c 5
- PING www.a.shifen.com (183.232.231.173) 56(84) bytes of data.
- 64 bytes from 183.232.231.173 (183.232.231.173): icmp_seq=1 ttl=54 time=34.7 ms
- 64 bytes from 183.232.231.173 (183.232.231.173): icmp_seq=2 ttl=54 time=34.8 ms
- 64 bytes from 183.232.231.173 (183.232.231.173): icmp_seq=3 ttl=54 time=34.9 ms
- 64 bytes from 183.232.231.173 (183.232.231.173): icmp_seq=4 ttl=54 time=34.5 ms
- 64 bytes from 183.232.231.173 (183.232.231.173): icmp_seq=5 ttl=54 time=34.6 ms
- --- www.a.shifen.com ping statistics ---
- 5 packets transmitted, 5 received, 0% packet loss, time 4006ms
- rtt min/avg/max/mdev = 34.558/34.741/34.928/0.208 ms
- [root@master etc]#