linux日常管理,linux日常管理2

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值