Chinaunix首页 | 论坛 | 博客
  • 博客访问: 573165
  • 博文数量: 117
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 359
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-13 21:58
个人简介

爱上香烟

文章分类

全部博文(117)

文章存档

2018年(3)

2017年(8)

2016年(65)

2015年(41)

我的朋友

分类: LINUX

2016-04-06 13:52:12

for((i=0;i<4;i++)){
 eval  'lan'"$i=`brctl show|grep eth$i|awk '{print $1}'`"
 eval  echo '$lan'$i
 eval kk='$'lan$i
 echo "kk=$kk"
}
#===============================================================
#iptables -t nat -A POSTROUTING -o br.phy.1 -j MASQUERADE
#iptables -t nat -A POSTROUTING -o br.phy.3 -j MASQUERADE


#=================================
#echo "1 wan1" >> /etc/iproute2/rt_tables
#echo "2 wan2" >> /etc/iproute2/rt_tables
#=================================
echo " 请WAN1的网关"
read wan1_gateway
echo " 请WAN2的网关"
read wan2_gateway


net1=`ip addr |grep br.phy.0 |grep inet|awk '{print $2}'`
echo "$net0"
net2=`ip addr |grep br.phy.1 |grep inet|awk '{print $2}'`
echo "$net1"


echo "1 wan1" >> /etc/iproute2/rt_tables
#ip ru add from $net0 to $net1 table wan1 pref 10
ip ru add iif br.phy.0 table wan1 pref 10
ip ro add $net1 dev br.phy.1
ip ro rep default via $wan1_gateway dev br.phy.1 table wan1
iptables -t nat -A POSTROUTING -s $net0 -o br.phy.1 -j MASQUERADE
#=================================
net2=`ip addr |grep br.phy.2 |grep inet|awk '{print $2}'`
echo "$net2"
net3=`ip addr |grep br.phy.3 |grep inet|awk '{print $2}'`
echo "$net3"


echo "2 wan2" >> /etc/iproute2/rt_tables
##ip ru add from $net2 to $net3 table wan2 pref 20
ip ru add iif br.phy.2 table wan2 pref 20
ip ro add $net3 dev br.phy.3
ip ro rep default via $wan2_gateway dev br.phy.3 table wan2
iptables -t nat -A POSTROUTING -s $net2 -o br.phy.3 -j MASQUERADE

===========================给很多个网段进行伪装==================================
1.用ipset定义一个IP set:
ipset -N my_policy ipmap --from 192.168.1.1 --to 192.168.1.100
ipset -A my_policy 192.168.2.0/24
ipset -A my_policy 192.168.3.0/24
ipset -A my_policy 192.168.4.0/24
..........
..........
2.iptables使用这个IP set:
iptables -t filter -A FORWARD -m set --match-set my_policy src -o br.phy.3 -j MASQUERADE

阅读(1709) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~