云路由 vyatta 体验(六)防火墙

 

vyatta提供了强大的基于iptables的高级防火墙功能。

如果你没有定义防火墙,vyatta默认策略会禁止所有入站端口,放行所有出站。

 

vyatta的防火墙使用规则是这样的

1、定义好规则模板

2、将规则置于网卡之上生效

 

比如开放http端口到公网

 
 

 

 
 
  1. set firewall name LAN-IN default-action drop 
  2. set firewall name LAN-IN rule 10 action accept  
  3. set firewall name LAN-IN rule 10 description "allow http access from public"  
  4. set firewall name LAN-IN rule 10 protocol tcp  
  5. set firewall name LAN-IN rule 10 destination port http  
  6.   
  7. 这样就放行了所有对公网的web访问  

 

再比如要限制公网的ssh访问

 
 
  1. set firewall name LAN-IN rule 20 action accept  
  2. set firewall name LAN-IN rule 20 description "allow ssh access from some IP"  
  3. set firewall name LAN-IN rule 20 protocol tcp  
  4. set firewall name LAN-IN rule 20 destination port ssh 
  5. set firewall name LAN-IN rule 20 source address 202.96.134.133  

 

再比如限制对内某台机器的访问,譬如邮件服务器

 
 
  1. set firewall name LAN-IN rule 30 action accept  
  2. set firewall name LAN-IN rule 30 description "allow smtp access from public to mail server"  
  3. set firewall name LAN-IN rule 30 protocol tcp  
  4. set firewall name LAN-IN rule 30 destination port smtp  
  5. set firewall name LAN-IN rule 30 destination address 10.0.0.8 

 

状态防火墙

 

 
 
  1. set firewall name STATE-RULE default-action drop 
  2. set firewall name STATE-RULE description "Filter traffic statefully"  
  3. set firewall name STATE-RULE rule 1 action accept  
  4. set firewall name STATE-RULE rule 1 state established enable  
  5. set firewall name STATE-RULE rule 1 state related enable  
  6.   
  7. set firewall name STATE-RULE rule 2 action drop  
  8. set firewall name STATE-RULE rule 2 state invalid enable  
  9. set firewall name STATE-RULE rule 2 log enable  
  10.   
  11. commit  

 

 

将上面的策略放在公网网卡上

 

 
 
  1. set interfaces ethernet eth1 firewall in name LAN-IN  
  2. set interfaces ethernet eth1 firewall in name STATE-RULE 

 

 

注意上面的in,

在vyatta的防火墙中有三条通道

in 指的是入站

out 指的是出站

local 指的是防火墙本机 

 

vyatta的防火墙还有基于其他策略的高级规则链,这里略过,详情参考官网文档。

 

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值