原文地址: http://tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.rpdb.simple.html

Linux Advanced Routing & Traffic Control HOWTO
Prev Chapter 4. Rules - routing policy database Next

4.1. Simple source policy routing

Let's take a real example once again, I have 2 (actually 3, about time I returned them) cable modems, connected to a Linux NAT ('masquerading') router. People living here pay me to use the Internet. Suppose one of my house mates only visits hotmail and wants to pay less. This is fine with me, but they'll end up using the low-end cable modem.

The 'fast' cable modem is known as 212.64.94.251 and is a PPP link to 212.64.94.1. The 'slow' cable modem is known by various ip addresses, 212.64.78.148 in this example and is a link to 195.96.98.253.

The local table:

[ahu@home ahu]$ ip route list table local
broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1
local 10.0.0.1 dev eth0 proto kernel scope host src 10.0.0.1
broadcast 10.0.0.0 dev eth0 proto kernel scope link src 10.0.0.1
local 212.64.94.251 dev ppp0 proto kernel scope host src 212.64.94.251
broadcast 10.255.255.255 dev eth0 proto kernel scope link src 10.0.0.1
broadcast 127.0.0.0 dev lo proto kernel scope link src 127.0.0.1
local 212.64.78.148 dev ppp2 proto kernel scope host src 212.64.78.148
local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1
local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1

Lots of obvious things, but things that need to be specified somewhere. Well, here they are. The default table is empty.

Let's view the 'main' table:

[ahu@home ahu]$ ip route list table main
195.96.98.253 dev ppp2 proto kernel scope link src 212.64.78.148
212.64.94.1 dev ppp0 proto kernel scope link src 212.64.94.251
10.0.0.0/8 dev eth0 proto kernel scope link src 10.0.0.1
127.0.0.0/8 dev lo scope link
default via 212.64.94.1 dev ppp0

We now generate a new rule which we call 'John', for our hypothetical house mate. Although we can work with pure numbers, it's far easier if we add our tables to /etc/iproute2/rt_tables.

# echo 200 John >> /etc/iproute2/rt_tables
# ip rule add from 10.0.0.10 table John
# ip rule ls
0: from all lookup local
32765: from 10.0.0.10 lookup John
32766: from all lookup main
32767: from all lookup default

Now all that is left is to generate John's table, and flush the route cache:

# ip route add default via 195.96.98.253 dev ppp2 table John
# ip route flush cache

And we are done. It is left as an exercise for the reader to implement this in ip-up.


Prev Home Next
Rules - routing policy database Up Routing for multiple uplinks/providers

zt-Simple source policy routing的更多相关文章

  1. A Quick Introduction to Linux Policy Routing

    A Quick Introduction to Linux Policy Routing 29 May 2013 In this post, I’m going to introduce you to ...

  2. iproute2学习笔记

    一.替代arp, ifconfig, route等命令 显示网卡和IP地址 root@openstack:~# ip link list 1: lo: <LOOPBACK,UP,LOWER_UP ...

  3. partial.js client-side routing(客户端路由-基于HTML5 SPA特性的历史API)

    partial.js client-side routing https://github.com/petersirka/partial.js-clientside Framework support ...

  4. (转)RL — Policy Gradient Explained

    RL — Policy Gradient Explained 2019-05-02 21:12:57 This blog is copied from: https://medium.com/@jon ...

  5. Source Insight 中的 Auto Indenting

    编码过程中,希望输入花括号时能自动对齐,Source Insigth 应如何设置? 先来看一下Source Insight 中的帮助. “ Auto Indenting The auto-indent ...

  6. Linux就这个范儿 第16章 谁都可以从头再来--从头开始编译一套Linux系统 nsswitch.conf配置文件

    Linux就这个范儿 第16章 谁都可以从头再来--从头开始编译一套Linux系统  nsswitch.conf配置文件 朋友们,今天我对你们说,在此时此刻,我们虽然遭受种种困难和挫折,我仍然有一个梦 ...

  7. Cisco IOS Debug Command Reference I through L

    debug iapp through debug ip ftp debug iapp : to begin debugging of IAPP operations(in privileged EXE ...

  8. vyos User Guide

    vyos User Guide 来源 https://wiki.vyos.net/wiki/User_Guide The VyOS User Guide is focused on providing ...

  9. OPENVPN2.3配置文档官方说明

    openvpn Section: Maintenance Commands (8)Index NAME openvpn - secure IP tunnel daemon. SYNOPSIS open ...

随机推荐

  1. python模块介绍- SocketServer 网络服务框架

    来源:https://my.oschina.net/u/1433482/blog/190612 摘要: SocketServer简化了网络服务器的编写.它有4个类:TCPServer,UDPServe ...

  2. 今年几个项目中用到的一个jqueryTab插件感觉挺好用的

    名字叫:wdscrolltab 开源中国项目地址: http://www.oschina.net/p/wdscrolltab

  3. 双击vbs时,默认cscript运行脚本

    Dim obj_shellset obj_shell = createobject("wscript.shell")host = WScript.FullNameIf LCase( ...

  4. 2008server安装Intel I217V网卡驱动

    问题:由于在职的是小公司,公司服务器都是DIY的,拒绝采购品牌服务器,所以配件都是自己DIY的,这样就会出现很多兼容性问题,例如服务器主板是AUS B85-PRO-Gamer,装的是服务器系统wind ...

  5. 初学matlab----函数用法(随学习更新中)

    sort(A) 若A是向量不管是列还是行向量,默认都是对A进行升序排列. sort(A)是默认的升序,而sort(A,'descend')是降序排序. sort(A)若A是矩阵,默认对A的各列进行升序 ...

  6. 【转】awk、nawk、mawk、gawk的简答介绍

    来自http://blog.sina.com.cn/s/blog_3d2d79aa0100h47h.html awk 是一种编程语言,用于在linux/unix下对文本和数据进行处理.数据可以来自标准 ...

  7. mysql 重复数据防止插入:)

    insert into table (id, name, age) values(1, "A", 19) on duplicate key update name=values(n ...

  8. CSS3常用选择器(一)

    在 CSS 中,选择器是一种模式,用于选择需要添加样式的元素.比如最常用到的#id,.class,标签选择器. 随着CSS3到来,增加了很多新型选择器,这里就常用的做一个总结. 1.属性选择器. 在c ...

  9. MFCC matlab code

    %function ccc=mfcc(x) %归一化mel滤波器组系数 filename=input('input filename:','s'); [x,fs,bits]=wavread(filen ...

  10. memory allocation

    1 malloc与free是C++/C语言的标准库函数,new/delete是C++的运算符. 2,malloc, 必须 包含头文件<stdlib.h> 3, nt* p_scalar = ...