[toc]網絡
重啓CentOS後,出現以下登入界面工具
在localhost login:後面輸入root並回車,而後輸入以前設置的ROOT密碼,進入系統,如圖所示:oop
[root@localhost ~]# ls anaconda-ks.cfg initial-setup-ks.cfg [root@localhost ~]# ls /tmp systemd-private-326256f65ea943dd8a67183d93dfe298-cups.service-AeQUKR systemd-private-326256f65ea943dd8a67183d93dfe298-vmtoolsd.service-4S9XrS [root@localhost ~]# ls /boot config-3.10.0-514.el7.x86_64 grub grub2 initramfs-0-rescue-9c050f10e0134ad9b8b954df8080769f.img initramfs-3.10.0-514.el7.x86_64.img initramfs-3.10.0-514.el7.x86_64kdump.img initrd-plymouth.img symvers-3.10.0-514.el7.x86_64.gz System.map-3.10.0-514.el7.x86_64 vmlinuz-0-rescue-9c050f10e0134ad9b8b954df8080769f vmlinuz-3.10.0-514.el7.x86_64
(1) 輸入如下命令,自動獲取IP地址測試
#dhclient
(2) 輸入一下命令, #ip addr3d
[root@localhost ~]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:ea:14:79 brd ff:ff:ff:ff:ff:ff inet 192.168.72.130/24 brd 192.168.72.255 scope global ens33 valid_lft forever preferred_lft forever inet6 fe80::1d7a:ffe8:8235:a2a5/64 scope link valid_lft forever preferred_lft forever
[root@localhost ~]# ls /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
須要手動修改起內容,按字母i鍵,出現insertrest
~ ~ ~ ~ ~ -- INSERT --
IPADDR=192.168.72.130 NETMASK=255.255.255.0 GATEWAY=192.168.72.2 DNS1=119.29.29.29
完整輸入以下:code
TYPE=Ethernet BOOTPROTO=static DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 UUID=3b000477-c3db-4855-b5ba-c73bb1546b3a DEVICE=ens33 ONBOOT=yes IPADDR=192.168.72.130 NETMASK=255.255.255.0 GATEWAY=192.168.72.2 DNS1=119.29.29.29
*注意:**BOOTPROTO用來設置網卡的啓動類型,dhcp表示自動獲取,static表示手動設置靜態IP地址,ONBOOT設置成yes表示網卡隨系統一同啓動,IPADDR指定IP地址,NETMASK指定子網掩碼,GATEWAY指定網關,DNS制定DNS,這裏能夠設置多個DNS,119.29.29.29是國內DNSpod公司提供的一個公關DNS。ip
完成以上更改後,按一下Esc鍵,輸入「:wq」 而後回車,退出剛纔文檔。文檔
# systemctl restart network.service
而後查看一下IPit
# ifconfig
若是正確,再測試一下外網是否通暢,輸入命令:
# ping www.baidu.com