1:查看网卡的DNS的配置文件:
注:不需要修改.
[root@localhost ~]# cat /etc/resolv.conf # Generated by NetworkManager search lan nameserver fd7b:ac2f:6d73::1
注:在重启网络服务[service network restart]后,
系统会自动使用[/etc/sysconfig/network-scripts/ifcfg-enp0s3]中eg:DNS1=8.8.8.8,
自动设置[/etc/resolv.conf]中nameserver的配置为eg:nameserver 8.8.8.8,
此为自动设置成功,手动设置,重启网络服务将被覆盖或清空!
系统会自动使用[/etc/sysconfig/network-scripts/ifcfg-enp0s3]中eg:DNS1=8.8.8.8,
自动设置[/etc/resolv.conf]中nameserver的配置为eg:nameserver 8.8.8.8,
此为自动设置成功,手动设置,重启网络服务将被覆盖或清空!
设置参数:
8.8.8.8 #google域名服务器 8.8.4.4 #google域名服务器 192.168.10.1 #网卡对应的网关的IP地址(默认网关) 255.255.255.0 #网卡对应的网络掩码(子网掩码) 192.168.10.56 #网卡对应的ip地址
2:修改网卡的网关的配置文件:
[root@localhost sysconfig]# pwd /etc/sysconfig [root@localhost sysconfig]# vim network [root@localhost sysconfig]# cat network
# Created by anaconda NETWORKING=yes HOSTNAME=CentOS-Slave1 NETWORKING_IPV6=no PEERNTP=no GATEWAY=192.168.10.1
注:设置本机的主机名,这里设置的主机名要/etc/sysconfig/network和/etc/hosts中设置的主机名对应一致(可选)
3:修改网卡的IP地址的配置文件:
[root@CentOS-Slave1 network-scripts]# pwd /etc/sysconfig/network-scripts [root@CentOS-Slave1 network-scripts]# vim ifcfg-enp0s3 [root@CentOS-Slave1 network-scripts]# cat ifcfg-enp0s3
DEVICE=enp0s3 ONBOOT=yes BOOTPROTO=static IPADDR=192.168.10.56 NETMASK=255.255.255.0 DNS1=8.8.8.8 DNS2=8.8.4.4
centos7详细配置见,备注附件!
4:修改主机名配置文件:
注:手动添加ip和主机名,第三行.
注:手动添加ip和主机名,第三行.
[root@localhost etc]# pwd /etc [root@localhost etc]# vim hosts [root@localhost etc]# cat hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.10.56 CentOS-Slave1
5:重启网络服务:
[root@localhost init.d]# service network restart Restarting network (via systemctl): [ OK ]
6:再次查看网卡的DNS的配置文件:
[root@localhost init.d]# cat /etc/resolv.conf # Generated by NetworkManager search lan lan. nameserver 8.8.8.8 nameserver 8.8.4.4 nameserver fd7b:ac2f:6d73::1注:DNS已经配置完毕!
7:查看主机名称[重启生效]:
[root@localhost init.d]# hostname CentOS-Slave1
查看ip:
[root@CentOS-Slave1 /]# ifconfig enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.10.56 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::a00:27ff:fe87:b3c0 prefixlen 64 scopeid 0x20<link> ether 08:00:27:87:b3:c0 txqueuelen 1000 (Ethernet) RX packets 44075 bytes 47664947 (45.4 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 9704 bytes 1365665 (1.3 MiB) 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 0 (Local Loopback) RX packets 3 bytes 303 (303.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3 bytes 303 (303.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
详细讲解ip配置查看:
CentOS的ip设置/Ubuntu的ip设置:在Oracle VM VirtualBOX下CentOS 7/Ubuntu 系统设置网络:接入internet(上网)和 局域网 ip
备注附件:
DEVICE=enp0s3 TYPE=Ethernet BOOTPROTO=static ONBOOT=yes 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 NAME=enp0s3 UUID=f4ff103e-5adc-4456-b338-d66b1b63bb46 IPADDR=192.168.10.56 NETMASK=255.255.255.0 DNS1=8.8.8.8 DNS2=8.8.4.4