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

linux 双线 路由器服务

时间:2017-05-04 14:39:48      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:for   etc   iproute   dna   nat   ifconfig   null   net   table   

#Set ip.
ifconfig ${nic}   192.168.2.254/24  up
ifconfig ${nic}:0 192.168.22.254/24 up
ifconfig ${nic}:1 124.133.33.114/30 up
ifconfig ${nic}:2 58.58.27.223/24   up
ifconfig ${nic}:3 192.168.2.2/24    up
ifconfig ${nic}:4 100.100.100.100/24 up
 
#Conf Main Table.
ip route add 192.168.1.0/24 via 192.168.2.250
ip route add 192.168.3.0/24 via 192.168.2.250
ip route add 192.168.4.0/24 via 192.168.2.250
ip route add 192.168.5.0/24 via 192.168.2.250
ip route add 192.168.6.0/24 via 192.168.2.250
 
#Turn on forwarding. 
echo 1 >/proc/sys/net/ipv4/ip_forward
 
#mondify the file "/etc/iproutes/rt_tables"
 echo -e ‘100 tel\n200 cnc‘ >>.rt_tables.tmp
 
#Config rule and routing tables.
ip route replace default via 58.58.27.1
 
ip rule add from 124.133.33.114 table tel
ip route flush table tel >/dev/null 2>&1
ip route add 124.133.33.112/30 src 124.133.33.114 dev ${nic}:1 table tel
ip route add 192.168.4.0/24 via 192.168.2.250 table tel
ip route add 192.168.5.0/24 via 192.168.2.250 table tel
ip route add default via 124.133.33.113 table tel
 
ip rule add from 58.58.27.223 table cnc
ip route flush table cnc >/dev/null 2>&1
ip route add 58.58.27.0/24 src 58.58.27.223 dev ${nic}:2 table cnc
ip route add default via 58.58.27.1 table cnc
 
ip rule add fwmark 22 table tel
 
iptables -t mangle -F
iptables -t mangle -A PREROUTING -s 192.168.22.0/24 -j MARK --set-mark 22
 
iptables -t nat -F
#Config Fire Wall.[SNAT]
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j MASQUERADE
#Config Fire Wall.[DNAT]

linux 双线 路由器服务

标签:for   etc   iproute   dna   nat   ifconfig   null   net   table   

原文地址:http://www.cnblogs.com/gipagod/p/6806579.html

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