码迷,mamicode.com
首页 > 系统相关 > 详细

linux日常管理2

时间:2017-01-12 03:35:17      阅读:303      评论:0      收藏:0      [点我收藏+]

标签:linux

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编辑此文件


linux日常管理2

标签:linux

原文地址:http://9872158.blog.51cto.com/9862158/1891050

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!