/* Centos7 的網絡 不能夠用ifconfig獲取,須要安裝包 因此 。*/ //查看ip [root@master ~]# ip a /* Centos7 的網卡名字與 Centos6有區別,要注意!*/ //獲取網卡ip [root@master ~]# dhclient + 網卡名字 /*若是配置了兩張網卡,極可能第二張沒辦法獲取,由於進程一直存在。 因此咱們先獲取一張,而後去到遠程鏈接。 */
PS: 在Centos7 ,沒有下載包也沒有 kill這個功能,因此若是要從新再獲取ip ,能夠使用 [ dhclient -r ] 刪除全部獲取的ip
PS2: 在VMware的窗口, 菜單 --〉 編輯 --〉虛擬網絡編輯器 --〉 能夠查看到咱們網卡的「範圍」 --〉能夠根據這個「範圍」來定咱們的ip
/* 遠程鏈接太慢 */ [root@master ~]# vi /etc/ssh/sshd_config //find 「UseDNS」 --〉改爲 #UseDNS yes --> change --> UseDNS no //restart sshd [root@master ~]# systemctl restart sshd
/* 先修改第一張網卡的配置文件 */ [root@master network-scripts]# vi ifcfg-eno33554960 //改爲 HWADDR=00:0C:29:93:D2:0C TYPE=Ethernet BOOTPROTO=none AME=eno33554960 UUID=03954cb0-006a-479f-bee4-fb932fc40df3 ONBOOT=yes IPADDR=192.168.238.128 NETMASK=255.255.255.0 /* 再修改第二張網卡的配置文件 */ [root@master network-scripts]# vi ifcfg-eno16777736 //改爲 HWADDR=00:0C:29:93:D2:02 TYPE=Ethernet BOOTPROTO=static #DEFROUTE=yes PEERDNS=no #這裏寫了no,下面咱們則不須要寫DNS #PEERROUTES=yes #IPV4_FAILURE_FATAL=no #IPV6INIT=yes #IPV6_AUTOCONF=yes #IPV6_DEFROUTE=yes #IPV6_PEERDNS=yes #IPV6_PEERROUTES=yes #IPV6_FAILURE_FATAL=no NAME=eno16777736 UUID=b0c78a01-8dc6-4883-be07-7e237076a6ce ONBOOT=yes IPADDR=192.168.216.120 NETMASK=255.255.255.0 GATEWAY=192.168.216.2 //重啓網絡 [root@master network-scripts]# systemctl restart network [root@master network-scripts]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 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: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:93:d2:02 brd ff:ff:ff:ff:ff:ff inet 192.168.216.120/24 brd 192.168.216.255 scope global eno16777736 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe93:d202/64 scope link valid_lft forever preferred_lft forever 3: eno33554960: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:93:d2:0c brd ff:ff:ff:ff:ff:ff inet 192.168.238.128/24 brd 192.168.238.255 scope global eno33554960 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe93:d20c/64 scope link valid_lft forever preferred_lft forever [root@master network-scripts]# vi /etc/resolv.conf //修改nameserver ; generated by /usr/sbin/dhclient-script search localdomain nameserver 119.29.29.29 //測試是否聯網 [root@master network-scripts]# ping www.qq.com PING www.qq.com (117.135.169.41) 56(84) bytes of data. 64 bytes from . (117.135.169.41): icmp_seq=1 ttl=128 time=5.62 ms 64 bytes from . (117.135.169.41): icmp_seq=2 ttl=128 time=5.56 ms ^C --- www.qq.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1013ms rtt min/avg/max/mdev = 5.566/5.594/5.623/0.080 ms