分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 教程案例

2018.5.8 七周三次课(firewalld和netfilter,iptables语法)

发布时间:2023-09-06 01:53责任编辑:顾先生关键词:暂无标签
Linux网络相关

centOS版本6里,如果想用ifconfig 得安装个net-tools

 ????[root@localhost ~]# yum install -y net-tools

关闭一个网卡

 ???[root@localhost ~]# ifdown ens33

开启网卡

 ???[root@localhost ~]# ifup ens33

重启网卡

 ???[root@localhost ~]# ifdown ens33 && ifup ens33

添加一个虚拟网卡

 ???[root@localhost ~]# cd /etc/sysconfig/network-scripts/ ???[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens33\:0 ???#进入到配置文件,拷贝一份IP目录,然后修改名为ens33:0,这里的“\”是为了脱义冒号

修改虚拟网卡的配置文件

 ???[root@localhost network-scripts]# vi ifcfg-ens33:0 ???这里就编辑三个地方就可以,NAME和DEVICE还有IP地址 ???然后重启网卡: ???[root@localhost network-scripts]# ifdown ens33 && ifup ens33


添加成功。

查看一个网卡有没有插着网线

 ???[root@localhost network-scripts]# mii-tool ens33 #后面跟网卡的名字 ???ens33: negotiated 1000baseT-FD flow-control, link ok #看看后面是不是ok

修改主机名 hostnamectl set-hostname zhang-01

 ???[root@localhost ~]# hostnamectl set-hostname zhang-01 ???[root@localhost ~]# bash #打开一个子shell看下是否修改成功 ???[root@zhang-01 ~]# 

DNS配置文件在 /etc/resolv.conf

 ???[root@zhang-01 ~]# cat /etc/resolv.conf ????# Generated by NetworkManager ???nameserver 119.29.29.29 ???nameserver 114.114.114.114

firewalld和netfilter(防火墙)

Linux防火墙-netfilter:selinux临时关闭 setenforce 0 selinux永久关闭 vi /etc/selinux/config centos7之前使用netfilter防火墙 centos7开始使用firewalld防火墙 关闭firewalld开启netfilter方法 systemctl stop firewalld 服务关掉 systemctl disable firewalled 关闭firewalled 不让开机启动 yum install -y iptables-services 如果再开启firewalled需要安装一个包 systemctl enable iptables ?systemctl start iptables 开启

永久关闭防火墙,编辑配置文件 SELINUX=enforcing修改成disabled

 ???[root@zhang-01 ~]# vi /etc/selinux/config 

查看iptables服务

 ???[root@zhang-01 ~]# iptables -nvL #可以查看里面默认的规则 5表5列

Linux防火墙-netfilter

netfilter的5个表 filter表用于过滤包,最常用的表,有INPUT、FORWARD、OUTPUT三个链 nat表用于网络地址转换,有PREROUTING、OUTPUT、POSTROUTING三个链 managle表用于给数据包做标记,几乎用不到 raw表可以实现不追踪某些数据包,阿铭从来不用

2018.5.8 七周三次课(firewalld和netfilter,iptables语法)

原文地址:http://blog.51cto.com/13646023/2114187

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved