龙空技术网

CentOS7网络配置和服务管理

梦幻泡空 697

前言:

目前大家对“centos7service”大体比较关切,各位老铁们都想要剖析一些“centos7service”的相关知识。那么小编同时在网上汇集了一些对于“centos7service””的相关内容,希望姐妹们能喜欢,姐妹们快快来了解一下吧!

一、配置网络

1.通过编辑文件修改网络配置

vi /etc/sysconfig/network-scripts/ifcfg-eno160

HWADDR=00:0c:29:14:34:51

TYPE=Ethernet

BOOTPROTO=static

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

USERCTL=no

NM_CONTROLLED=no

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes

IPV6_FAILURE_FATAL=no

NAME=eno160

ONBOOT=yes

IPADDR=192.168.117.128

NETMASK=255.255.255.0

GATEWAY=192.168.117.2

DNS1=192.168.117.2

关键配置:

TYPE=Ethernet

BOOTPROTO=static

NAME=eno160

ONBOOT=yes

IPADDR=192.168.117.128

NETMASK=255.255.255.0

GATEWAY=192.168.117.2

DNS1=192.168.117.2

cat /etc/resolv.conf

nameserver 192.168.117.2

2.通过文本工具nmtui修改网络配置

yum -y install NetworkManager-tui

nmtui-edit eno160 修改网卡配置

nmtui-connect eno160

重启网络

systemctl restart network

systemctl status network

修改主机名:

vi /etc/hostname

centos

退出重新登录即可生效

二、关闭不必要的服务

最小化安装的Centos7系统并没有nano、vim、wget、curl、ifconfig、lsof命令,这里首先安装一下:

yum -y install nano vim wget curl net-tools lsof

可以通过netstat和lsof查看系统都运行了哪些服务,将不必要的进行关闭

systemctl stop postfix

systemctl stop avahi-daemon

systemctl disable postfix

systemctl disable avahi-daemon

systemctl list-unit-files 查看正在运行服务的状态报告

systemctl start httpd.service 启动服务

systemctl stop httpd.service 关闭服务

systemctl restart httpd.service 重启服务

systemctl reload httpd.service 重新加载服务

systemctl disable httpd.service 开机不启动

systemctl enable httpd.service 开机启动

systemctl status httpd.service 查看服务运行状态

systemctl show httpd.service 显示服务或任务的属性

systemctl list-dependencies httpd.service 检查服务依赖关系

systemctl is-enabled httpd.service 检查服务是否开机启动及级别

systemctl -H 192.168.111.11 start httpd.service 启动192.168.111.11机器上的httpd服务

标签: #centos7service #centos7桌面版配置网络环境