记录虚拟机安装完成后的初始配置:

1、网络: 桥接方式,设置静态ip,与物理机同一网段

Ip配置

配置完成 service network restart ,重启网络后 物理机可ssh连接虚拟机系统。 NAT模式比较方便,但虚拟机不暴露真实IP,不详述。

ping外网服务未知,此时应外网不通,需设置dns vi /etc/resolv.conf

route -n 检查路由 route add default gw 192.168.1.1 添加路由

2、安装iptables 防火墙 CentOS7默认的防火墙不是iptables,而是firewalle. 安装iptableiptable-service

#先检查是否安装了iptables service iptables status

#安装iptables yum install -y iptables

#升级iptables yum update iptables

#安装iptables-services yum install iptables-services 禁用/停止自带的firewalld服

#停止firewalld服务 systemctl stop firewalld #禁用firewalld服务 systemctl mask firewalld 设置现有规则

#查看iptables现有规则 iptables -L -n

#先允许所有,不然有可能会杯具 iptables -P INPUT ACCEPT

#清空所有默认规则 iptables -F 清空所有自定义规则 iptables -X

#所有计数器归0 iptables -Z

#允许来自于lo接口的数据包(本地访问) iptables -A INPUT -i lo -j ACCEPT

#开放22端口 iptables -A INPUT -p tcp --dport 22 -j ACCEPT

#开放21端口(FTP) iptables -A INPUT -p tcp --dport 21 -j ACCEPT

#开放80端口(HTTP) iptables -A INPUT -p tcp --dport 80 -j ACCEPT

#开放443端口(HTTPS) iptables -A INPUT -p tcp --dport 443 -j ACCEPT

#允许ping iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT

#允许接受本机请求之后的返回数据 RELATED,是为FTP设置的 iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

#其他入站一律丢弃 iptables -P INPUT DROP

#所有出站一律绿灯 iptables -P OUTPUT ACCEPT

#所有转发一律丢弃 iptables -P FORWARD DROP 其他规则设定

#如果要添加内网ip信任(接受其所有TCP请求) iptables -A INPUT -p tcp -s 45.96.174.68 -j ACCEPT

#过滤所有非以上规则的请求 iptables -P INPUT DROP

#要封停一个IP,使用下面这条命令: iptables -I INPUT -s ***.***.***.*** -j DROP

#要解封一个IP,使用下面这条命令: iptables -D INPUT -s ***.***.***.*** -j DROP 保存规则设定

#保存上述规则 service iptables save 开启iptables服务

#注册iptables服务

#相当于以前的chkconfig iptables on systemctl enable iptables.service

#开启服务 systemctl start iptables.service

#查看状态 systemctl status iptables.service 解决vsftpd在iptables开启后,无法使用被动模式的问题

  1.首先在/etc/sysconfig/iptables-config中修改或者添加以下内容 #添加以下内容,注意顺序不能调换 IPTABLES_MODULES="ip_conntrack_ftp" IPTABLES_MODULES="ip_nat_ftp"

  2.重新设置iptables设置 iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 以下为完整设置脚本

#!/bin/sh

iptables -P INPUT ACCEPT

iptables -F

iptables -X

iptables -Z

iptables -A INPUT -i lo -j ACCEPT

iptables -A INPUT -p tcp --dport 22 -j ACCEPT

iptables -A INPUT -p tcp --dport 21 -j ACCEPT

iptables -A INPUT -p tcp --dport 80 -j ACCEPT

iptables -A INPUT -p tcp --dport 443 -j ACCEPT

iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT

iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

iptables -P INPUT DROP iptables -P OUTPUT ACCEPT

iptables -P FORWARD DROP

service iptables save

systemctl restart iptables.service

3、常用工具安装 yum -y install redhat-lsb* //安装 lsb_release yum -y install vim* //安装vim编辑器 yum -y install lrzsz //安装上传下载命令 yum install -y unzip zip //安装 zip unzip 命令

4、字符集查看 cat /etc/locale.conf locale locale -a echo $LANG env |grep LANG 修改配置文件

5、电源管理 /etc/systemd/logind.conf #HandlePowerKey按下电源键后的行为,默认power off #HandleSleepKey 按下挂起键后的行为,默认suspend #HandleHibernateKey 按下休眠键后的行为,默认hibernate #HandleLidSwitch 合上笔记本盖后的行为,默认suspend (改为lock;即合盖不休眠 ) systemctl restart systemd-logind 生效

6、centos7 yum 更新出现 [Errno 14] HTTP Error 404 - Not Found 的解决方法 yum clean all rpm --rebuilddb

7、文件权限修改 更改所有者: chown -R 用户 目录 更改权限: chmod -R 755 目录

8、CentOS7使用firewalld打开关闭防火墙与端口

1)firewalld的基本使用

启动: systemctl start firewalld

关闭: systemctl stop firewalld

查看状态: systemctl status firewalld

开机禁用 : systemctl disable firewalld

开机启用 :systemctl enable firewalld

2)systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。

启动一个服务:systemctl start firewalld.service

关闭一个服务:systemctl stop firewalld.service

重启一个服务:systemctl restart firewalld.service

显示一个服务的状态:systemctl status firewalld.service

在开机时启用一个服务:systemctl enable firewalld.service

在开机时禁用一个服务:systemctl disable firewalld.service

查看服务是否开机启动:systemctl is-enabled firewalld.service

查看已启动的服务列表:systemctl list-unit-files|grep enabled

查看启动失败的服务列表:systemctl --failed

3)配置firewalld-cmd

查看版本: firewall-cmd --version

查看帮助: firewall-cmd --help

显示状态: firewall-cmd --state

查看所有打开的端口: firewall-cmd --zone=public --list-ports

更新防火墙规则: firewall-cmd --reload

查看区域信息: firewall-cmd --get-active-zones

查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0

拒绝所有包:firewall-cmd --panic-on

取消拒绝状态: firewall-cmd --panic-off

查看是否拒绝: firewall-cmd --query-panic

那怎么开启一个端口呢添加firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent永久生效,没有此参数重启后失效)

重新载入:firewall-cmd --reload

查看: firewall-cmd --zone=public --query-port=80/tcp

删除:firewall-cmd --zone=public --remove-port=80/tcp --permanent

############安装常用的软件#####################

yum -y install net-tools

yum -y vim unzip lrzsz 
配置时间付服务器
yum -y install ntpdate
yum install ntp //安装ntp服务 
systemctl enable ntpd //开机启动服务
systemctl start ntpd //启动服务
timedatectl set-timezone Asia/Shanghai //更改时区
timedatectl set-ntp yes //启用ntp同步
ntpq -p //同步时间

centos7基础配置的更多相关文章

  1. centos7基础配置及基础优化

    1    centos7安装及优化 1.1  通过U盘安装物理服务器注意事项(Dell R710) 使用U盘安装centos7,选择UEFI方式安装(最好修改BIOS为传统方式启动),在安装选择选项的 ...

  2. CentOS7 基础配置

    Centos 7 部分>>>>>>>>>>>>>>>>>>>>>>& ...

  3. SVN CentOS7 下配置svn的安装及基础配置介绍

    CentOS7 下配置svn的安装及基础配置介绍 by:授客 QQ:1033553122 目录 一. 二. 三. 四. 五. 六. 七. 一.      实践环境 CentOS 7操作系统(CentO ...

  4. YARN的基础配置

    基于HADOOP3.0+Centos7.0的yarn基础配置: 执行步骤:(1)配置集群yarn (2)启动.测试集群(3)在yarn上执行wordcount案例 一.配置yarn集群 1.配置yar ...

  5. virtualBox安装centos7并配置nginx php mysql运行环境

    virtualBox安装centos7并配置nginx php mysql运行环境 一:virtualBox安装centos7并进行基础设置 1.下载dvd.iso安装文件,下载地址:https:// ...

  6. ansible基础配置

    1.基础配置 1.1.环境 主机配置 ansible版本:2.7.4 控制端:centos7.4,IP:192.168.1.213,主机名:operation 被控制端: centos6.5,IP:1 ...

  7. 20.centos7基础学习与积累-006-软实力-画图

    从头开始积累centos7系统运用 亿图是用指南 安装亿图软件 修改基础配置 路径:文件==>选项==>常规 需要修改的参数: 撤销次数:256 自动保存间隔:2分钟 路径:文件==> ...

  8. StackExchange.Redis帮助类解决方案RedisRepository封装(基础配置)

    本文版权归博客园和作者吴双本人共同所有,转载和爬虫,请注明原文地址.http://www.cnblogs.com/tdws/p/5815735.html 写在前面 这不是教程,分享而已,也欢迎园友们多 ...

  9. Hibernate 基础配置及常用功能(三)

    本章重点讲述Hibernate对象的三种状态以及如何配置二级缓存 有关Hibernate的三种状态如何相互转换网上都能查到,官方文档描述的也比较详细.这里主要是针对几个重点方法做代码演示. 一.状态转 ...

随机推荐

  1. 重复执行shell脚本。

    while ((1)); do gclient runhooks; sleep 2; donewhile ((1)); do ifconfig; sleep 1; done

  2. caffe(13) 数据可视化(python接口)配置

    caffe程序是由c++语言写的,本身是不带数据可视化功能的.只能借助其它的库或接口,如opencv, python或matlab.大部分人使用python接口来进行可视化,因为python出了个比较 ...

  3. Windows10通过VNC远程连接Ubuntu18.04

    1.打开终端输入:sudo apt-get install xrdp vnc4server xbase-clients dconf-editor 2.接着在终端输入: 进入到下面这个界面: 接着按照这 ...

  4. Laravel+vue实现history模式URL可行方案

    项目:laravel + vue 实现前后端分离.vue-router 默认 hash 模式 -- 使用 URL 的 hash 来模拟一个完整的 URL,于是当 URL 改变时,页面不会重新加载. h ...

  5. storm 消息确认机制及可靠性

    worker进程死掉 在一个节点 kill work进程 比方 kill 2509  对work没有影响 由于会在其它节点又一次启动进程运行topology任务 supervisor进程死掉 supe ...

  6. 10010序列检测器的三段式状态机实现(verilog)

    序列检测器是时序数字电路设计中经典的教学范例,夏宇闻的<verilog数字系统设计教程>一书中有这个例子,用verilog设计一个“10010”序列的检测器.看完后我觉得F和G两个状态多余 ...

  7. Exception: Operation xx of contract xx specifies multiple request body parameters to be serialized without any wrapper elements.

    Operation 'CreateProductCodeStock' of contract 'IChileService' specifies multiple request body param ...

  8. Codeforces--602A--Two Bases(水)

    Two Bases Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit St ...

  9. 分析一下jquery中的ajax操作

    在web前端开发中,ajax是很重要的一项技术,用原生写起来很是麻烦,需要一大堆js代码,而到了jq里就被精简了许多,一起来看看: jquery中的ajax分为三种方式: 1.$.get(),get方 ...

  10. pig安装配置

    pig的安装配置很简单,只需要配置一下环境变量和指向hadoop conf的环境变量就行了 1.上传 2.解压 3.配置环境变量 Pig工作模式 本地模式:只需要配置PATH环境变量${PIG_HOM ...