Board logo

标题: CentOS8安装network服务 [打印本页]

作者: admin    时间: 2020-7-25 16:43     标题: CentOS8安装network服务

笺注:这是在 CentOS8安装LNMP+phpMyAdmin 的基础上进行的。 安装network服务: [root@centos8 ~]# yum -y install network-scripts 编辑网卡的IP地址、DNS地址等等: [root@centos8 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens160 TYPE="Ethernet" PROXY_METHOD="none" BROWSER_ONLY="no" BOOTPROTO="none" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" IPV6_ADDR_GEN_MODE="stable-privacy" NAME="ens160" UUID="bb322997-e819-4929-9afe-e3ac9338162d" DEVICE="ens160" ONBOOT="yes" IPADDR="192.168.168.154" PREFIX="24" GATEWAY="192.168.168.2" DNS1="8.8.8.8" DNS2="114.114.114.114" IPV6_PRIVACY="no" 重启network服务后,更改生效: [root@centos8 ~]# systemctl restart network 开机自动开启network服务: [root@centos8 ~]# systemctl enable network network.service is not a native service, redirecting to systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install enable network [root@centos8 ~]# [root@centos8 ~]# systemctl is-enabled network network.service is not a native service, redirecting to systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install is-enabled network enabled 最小化安装的话,会有一些命令没有安装: [root@centos8 ~]# which netstat /usr/bin/which: no netstat in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin) [root@centos8 ~]# [root@centos8 ~]# which ifconfig /usr/bin/which: no ifconfig in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin) [root@centos8 ~]# yum -y install net-tools [root@centos8 ~]# which netstat /usr/bin/netstat [root@centos8 ~]# [root@centos8 ~]# which ifconfig /usr/sbin/ifconfig 查看所有网卡: [root@centos8 ~]# ifconfig ens160: flags=4163 mtu 1500 inet 192.168.168.154 netmask 255.255.255.0 broadcast 192.168.168.255 inet6 fe80::92ab:5fb4:5373:ad53 prefixlen 64 scopeid 0x20 ether 00:0c:29:cb:1e:40 txqueuelen 1000 (Ethernet) RX packets 11289 bytes 10557647 (10.0 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 5005 bytes 1107050 (1.0 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 68 bytes 4624 (4.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 68 bytes 4624 (4.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 查看某张网卡: [root@centos8 ~]# ifconfig ens160 ens160: flags=4163 mtu 1500 inet 192.168.168.154 netmask 255.255.255.0 broadcast 192.168.168.255 inet6 fe80::92ab:5fb4:5373:ad53 prefixlen 64 scopeid 0x20 ether 00:0c:29:cb:1e:40 txqueuelen 1000 (Ethernet) RX packets 11302 bytes 10559758 (10.0 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 5018 bytes 1109034 (1.0 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 显示网卡的网关: [root@centos8 ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.168.2 0.0.0.0 UG 100 0 0 ens160 192.168.168.0 0.0.0.0 255.255.255.0 U 100 0 0 ens160 查看本机所使用的DNS服务器地址: [root@centos8 ~]# cat /etc/resolv.conf # Generated by NetworkManager search zhuohua.store nameserver 8.8.8.8 nameserver 114.114.114.114 注释:一般在网卡的配置文件上配置DNS地址。 [root@centos8 ~]# killall -bash: killall: 未找到命令 [root@centos8 ~]# dnf -y install psmisc [root@centos8 ~]# which killall /usr/bin/killall 测试: [root@centos8 ~]# systemctl start nginx [root@centos8 ~]# pgrep -l nginx 1483 nginx 1485 nginx [root@centos8 ~]# echo $? 0 [root@centos8 ~]# ps -ef |grep nginx |grep -v grep root 1483 1 0 14:22 ? 00:00:00 nginx: master process /usr/sbin/nginx nginx 1485 1483 0 14:22 ? 00:00:00 nginx: worker process [root@centos8 ~]# [root@centos8 ~]# echo $? 0 [root@centos8 ~]# netstat -anp |grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1483/nginx: master tcp6 0 0 :::80 :::* LISTEN 1483/nginx: master unix 3 [ ] STREAM CONNECTED 30962 1483/nginx: master unix 2 [ ] STREAM CONNECTED 30964 1485/nginx: worker unix 3 [ ] STREAM CONNECTED 30963 1483/nginx: master [root@centos8 ~]# echo $? 0 杀死Nginx的进程: [root@centos8 ~]# killall -9 nginx [root@centos8 ~]# [root@centos8 ~]# pgrep -l nginx [root@centos8 ~]# echo $? 1 [root@centos8 ~]# [root@centos8 ~]# ps -ef |grep nginx |grep -v grep [root@centos8 ~]# echo $? 1 [root@centos8 ~]# [root@centos8 ~]# netstat -anp |grep nginx [root@centos8 ~]# echo $? 1 相关文章: 最小化安装CentOS8 CentOS8_网络基础 CentOS6_网络基础




欢迎光临 blog.zhuohua.store (http://blog.zhuohua.store/) Powered by Discuz! 7.2