/*
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