保护网络通信

保护网络通信

作者:LAMP小白  点击:3599  发布日期:2014-06-08 14:38:30  返回列表

ssh 端口转发


ssh使用程序可以使用加密连接通过防火墙传输或代理网络通信。他通过称为ssh端口赚发功能实现上述操作,可以采用多种不同方法配置ssh端口转发。

ssh -L localport:remotehost:remoteport sshhost命令将通过安全通道将连接从客户端上的端口转发到sshhost,从而完成隧道。

[root@MIO-02 ~]# ssh -Nf -L 6688:localhost:22 192.168.1.92

[root@MIO-02 ~]# ssh -p 6688 root@localhost
The authenticity of host '[localhost]:6688 ([::1]:6688)' can't be established.
RSA key fingerprint is 75:4a:d5:86:8d:ab:b5:f3:7f:70:e5:2b:6e:b1:ea:28.
Are you sure you want to continue connecting (yes/no)? yes    
Warning: Permanently added '[localhost]:6688' (RSA) to the list of known hosts.
root@localhost's password:
Last login: Sat Jun  7 13:10:27 2014 from 192.168.1.163
[root@MIO-92 ~]# exit
logout


封包过滤


iptables命令

你可能使用过system-config-firewall来配置简单的防火墙,使用命令行工具iptables可以创建和管理更加高级的配置。

-vnL 在数字模式下,完整的列出所有规则
-A CHAIN <rule> -j <target> 将规则添加到末尾
-I CHAIN #<rule> -j <target> 将规则作为规则#插入链,如果没有#则作为第一个规则
-D CHAIN # 将规则#删除
-F CHAIN # 清空


规则匹配标准语法


源IP或网络 -s 192.168.1.0/24
目标IP或网络 -d 1.1.1.1
UDP/TCP和端口 -p udp --sport 68 --dport 67
ICMP和类型 -p icmp --icmp-type ech0-reply
入站网络接口 -i eth0
出站网络接口 -o eth0
连接跟踪 -m state --state ESTABLISHED,RELATED


NEW 封包开始新通信 将规则添加到连接跟踪表
ESTABLISHED 与连接跟踪表中的规则匹配的任一封包
RELATED 在某种程度上与ESTABLISHED通信相关的通信
INVALID 无法确定的封包





上一篇:网络监控 下一篇:快递查询API
0