设为首页 收藏本站
查看: 794|回复: 0

[经验分享] linux日常管理2

[复制链接]

尚未签到

发表于 2018-5-18 11:36:19 | 显示全部楼层 |阅读模式
  tcpdump
  [root@bogon ~]# tcpdump -i eth0 -nn
  tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
  listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
  21:53:05.239989 IP 192.168.100.115.22 > 192.168.100.5.4940: Flags [P.], seq 3529230262:3529230458, ack 1084415304, win 275, length 196
  21:53:05.244210 IP 192.168.100.115.22 > 192.168.100.5.4940: Flags [P.], seq 196:376, ack 1, win 275, length 180
  21:53:05.255071 IP 192.168.100.5.4940 > 192.168.100.115.22: Flags [.], ack 376, win 64534, length 0
  tcpdump -i eth0 -nn tcp  只抓TCP的包
  tcpdump -i eth0 -nn tcp and host 192.168.100.22  and port  1111  抓TCP 协议1111端口  IP地址为192.168.100.22 的包
  wireshark
  tshark -n -t a -R http.request -T fields -e "frame.time" -e "ip.src" -e "http.host" -e "http.request.method" -e "http.request.uri"
  可以显示访问http请求的域名以及uri
  SELINUX
  关闭  setenforce 0  临时关闭
  开启 getenforec 0  临时开启
  永久关闭跟开启   vim /etc/selinux/config   
  iptables
  filter表
  
  [root@bogon ~]# iptables -nvl    列出规则
  iptables v1.4.7: option `-nvl' requires an argument
  Try `iptables -h' or 'iptables --help' for more information.
  [root@bogon ~]# iptables -nvL
  Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
   pkts bytes target     prot opt in     out     source               destination         
  43613   23M ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
      0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           
     19  1268 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0  
  
  [root@bogon ~]# iptables -t filter -nvL   查看filter表
  Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
   pkts bytes target     prot opt in     out     source               destination         
  43670   23M ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
      0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           
     19  1268 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
     14   728 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
  81702   18M REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited
  
  [root@localhost ~]# iptables -F   删除所有规则
  [root@localhost ~]# iptables -Z   把包以及流量计数器置零
  -A/-D :增加删除一条规则;
  -I :插入一条规则,其实跟-A的效果一样;
  -p :指定协议,可以是tcp,udp或者icmp;
  --dport :跟-p一起使用,指定目标端口;
  --sport :跟-p一起使用,指定源端口;
  -s :指定源IP(可以是一个ip段);
  -d :指定目的IP(可以是一个ip段);
  -j :后跟动作,其中ACCEPT表示允许包,DROP表示丢掉包,REJECT表示拒绝包;
  -i :指定网卡(不常用,但有时候能用到);
  例子:iptables -A  INPUT -s 1.1.1.1 -p --sport 1234  -d 2.2.2.2 -p --dport 4321 -j DORP
  停掉iptables   service iptables stop
  配置完成后需要保存 service iptables save
  

  NAT表
  iptables -t nat -nvL
  mangle 表
  iptables -t mangle -nvL     
  iptables -P INPUT DROP  修改iptables的默认策略
  iptables备份  iptables-save >file.txt
  iptables恢复  iptables-restore < file.txt
  

  
  [root@bogon ~]# iptables -nvL --line-num
  Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
  num   pkts bytes target     prot opt in     out     source               destination         
  1    45047   23M ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
  2        0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           
  3       19  1268 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
  4       14   728 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
  可以通过左边的数字来删除

  iptables -D INPUT 2
  


  任务计划
  crontab -l  查看有哪些任务计划
  [root@bogon ~]# cat /etc/crontab
  SHELL=/bin/bash
  PATH=/sbin:/bin:/usr/sbin:/usr/bin
  MAILTO=root
  HOME=/
  

  # For details see man 4 crontabs
  

  # Example of job definition:
  # .---------------- minute (0 - 59)
  # |  .------------- hour (0 - 23)
  # |  |  .---------- day of month (1 - 31)
  # |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
  # |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
  # |  |  |  |  |
  # *  *  *  *  * user-name command to be executed
   分 时 日 月 周
  service crond start
  service crond status
  写入 crontab -e 里
  写入的文件在 cat /var/spool/cron/root  也可以直接用vim编辑此文件
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-461681-1-1.html 上篇帖子: linux中netstat命令 下篇帖子: LINUX学习(LINUX就该这么学)1
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表