日常运维_3

10.11 linux网络相关

ifconfig 查看网卡ip(yum install net-tools)

ifconfig –a 当你网卡没ip(或down掉)时可以查看到

ifup  ens33   开启ens33网卡

ifdown ens33 关闭ens33网卡(更改dns时可以这样用,相当于重启网卡)

ifdown ens33 && ifup ens33 可以两个命令一起执行,不用跑机房

 

设定虚拟网卡ens33:1

cd /etc/sysconfig/network-scripts/

cp ifcfg-ens33   ifcfg-ens33\:0 复制文件,\脱意

vi !$ 编辑上一个文件

0c93839ff8cccadefdf5e5914fcb8a22146.jpg

ifdown ens33 && ifup ens33 重启网卡。

44708d2bcf8663eb15257e4e376e9314998.jpg

mii-tool ens33查看网卡是否连接

ed734d0ed5762efee1b9317b83876979e36.jpg

ethtool ens33 也可以查看网卡是否连接

961f0d6e3cce19fdc834c257905e1b5780e.jpg

hostnamectl set-hostname aminglinux 更改主机名(centos6不支持)(bash   exit变更主机名)

cat /etc/hostname 主机名配置文件

/etc/resolv.conf  DNS配置文件

/etc/hosts  解析文件

 

 

10.12 firewalld和netfilter

 

Linux防火墙-netfilter

 

setenforce 0   selinux 临时关闭

vi /etc/selinux/config   selinux永久关闭(把enforcing改成disabled)

d844d9b96cd0a966f37e285d7145e1dbb21.jpg

getenforce 查看防火墙状态

centos7之前使用netfilter防火墙

centos7开始使用firewalld防火墙

关闭firewalld开启netfilter方法

systemctl disable firewalld 先把它停掉(不让他开机启动)

systemctl stop firewalld 在把服务关掉

firewalld—>close /disable +stop  关闭firewalld防火墙流程

yum install –y iptables-services 安装包

systenctl enable iptables  

systemctl start iptables 开启iptables服务

netfilter àopenàiptables-servicesàenable iptables /start iptables 开启netfilter防火墙流程

 

iptables –nvl 查看默认规则

 

10.13 netfilter5表5链介绍

netfilter的5个表 (man iptables 查看iptables的一些信息介绍)

filter表用于过滤包,最常用的表,有INPUT(数据包进来时经过的一个链),FORWARD(进入后的一个链),OUTPUT(出去之前的一个链)三个链

nat表用于网络地址转换,有PREROUTING(进来时更改数据包,),OUTPUT,POSTROUTING(出去时更改数据包,)三个链

managel表用于给数据包做标记,几乎用不到

raw表可以实现不追踪某些数据包,从来不用

security表在centos6中并没有,用于强制访问控制(MAC)的网络规则,

参考文章http://www.cnblogs.com/metoy/p/4320813.html

 

 

 

10.14 iptables语法

iptables  -nvL查看iptables默认规则

/etc/sysconfig/iptables规则保存文件

iptables –F 清空规则

service iptables save 保存规则到配置文件里

service iptables restart 重启服务都会加载配置文件里规则(这些操作都是针对filter表)

iptables –t nat  // -t指定表

iptables –Z 可以把计数器清零

iptables –A INPUT –s 192.168.188.1 –p tcp –sport 1234 –d 192.168.188.128 –dport 80 –j DROP

-A增加 –s指定来源 –p指定协议 1234来源端口 –d 目标ip跟端口, drop直接扔掉

iptables –I(/-A/-D) INPUT –s 1.1.1.1 –j DROP –D删除

iptables –I INPUT –p tcp –dport 80 –j DROP 简写,只写目标端口,必须指定协议。-I插入

iptables –I INPUT –s 192.168.1.0/24 –i eth0 –j

ACCEPT –i指定网卡

iptables –nvL –line-numbers把规则序列号打出来

 

iptables –D INPUT 1删除第1条规则

iptables –P INPUT DROP –P默认规则

iptables –P OUTPUT DROP 执行会断开远程

iptables –P ACCEPT  恢复默认

转载于:https://my.oschina.net/u/3959687/blog/2252679

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值