{{ v.name }}
{{ v.cls }}类
{{ v.price }} ¥{{ v.price }}
linux网络相关
ifconfig查看网卡(yuminstallnet-tools)
未安装的情况下只能使用ipaddr查看网卡
ifconfig-a(显示全部网卡,包括未启动的)
ifupens33/ifdownens33(前者启动网卡,后者关闭网卡)
重启某张网卡:ifupens33&&ifdownens33
设定虚拟网卡ens33:1
cd/etc/sysconfig/network-scripts/
cpifcfg-ens33ifcfg-nes33:0(需使用转义字符)
vim!$
修改成name=ens33:1
device=ens33:1
ip也需修改
ifupens33&&ifdownens33
mii-toolens33查看网卡是否连接(网线是否连接)
ethtoolens33也可以查看网卡是否连接(查看linkdetected是否为yes)
更改主机名hostnameectlset-hostnamexxx(bash需重启)
主机名配置文件存放在/etc/hostname
dns配置文件/etc/resolv.conf(从网卡的配置文件来,修改该文件只会临时生效,重启网卡后,又改为网卡配置里的)
/etc/hosts本机域名解析
格式:ip域名(域名)
若一个域名对应多个ip
以最底部的为主
linux防火墙-netfilter
selinux临时关闭setenforce0
用getenforce查看当前状态
selinux永久关闭vim/etc/selinux/config
修改selinux=disabled
重启系统
centos7之前使用netfilter防护墙
centos7开始使用firewalld防火墙
关闭firewalld开启netfilter方法:
systemctlstopfirewalld(关闭服务)
systemctldisablefirewalled(停止使用,不开机启动)
yuminstall-yiptables-services
systemctlenableiptable
systemctlstartiptables
netfilter的5个表:
filter表用于过滤包,最常用的表,有input、forward、output三个链
nat表用于网络地址转换,有prerouting、output、postrouting三个链
managle表用于给数据包做标记,几乎用不到
raw表可以实现不追踪某系数据包
security表,用于强制访问控制(mac)的网络(在centos6中并没有)
iptables-nvl(查看当前规则)
-n不对ip地址进行反查,加上这个参数显示速度会快很多
-v输出详细信息,包含通过该规则的数据包数量,总字节数及相应的网络接口
-l查看当前表的所有规则,默认查看的是filter表,如果要查看nat表,可以加上-tnat参数
规则存放在/etc/sysconfig/iptables
iptables-f清空规则
serviceiptablessave保存规则
iptables-tnat//-t指定表
iptables-z可以把计数器清零
iptables-ainput-s192.168.188.1-ptcp--sport1234-d192.168.188.128--dprot80-jdrop
(不使用-t参数默认为filter表,-a表示add增加规则,后面制定input链,-s来源ip,souces,-p指定协议,--sport来源端口,-d目标ip,--dport目标端口,操作drop丢弃)(drop、reject区别:一个有反馈一个没反馈)
使用--dport或者使用--sport必须使用-p指定协议
-i参数插入到最前面
-a参数增加在最后
-d参数删除规则
-i参数指定网卡
iptables优先匹配前面规则
iptables-i/-a/-dipput-s1.1.1.1-jdrop
iptables-iinput-s192.168.1.0/24-ieth0-jaccept
iptables-nvl--line-numbers(--line-numbers显示规则号)
iptables-dinput1(删除规则1)