struct fib_table *fib_tables[RT_TABLE_MAX+1]; // RT_TABLE_MAX 为255 |
struct fib_table { unsigned char tb_id; unsigned tb_stamp; int (*tb_lookup)(struct fib_table *tb, const struct flowi *flp, struct fib_result *res); int (*tb_insert)(struct fib_table *table, struct rtmsg *r, …… void (*tb_select_default)(struct fib_table *table, const struct flowi *flp, struct fib_result *res); unsigned char tb_data[0]; }; |
struct fn_hash { struct fn_zone *fn_zones[33]; struct fn_zone *fn_zone_list; }; |
struct fn_zone { struct fn_zone *fz_next; /* Next not empty zone */ struct hlist_head *fz_hash; /* Hash table pointer */ int fz_nent; /* Number of entries */ int fz_divisor; /* Hash divisor */ u32 fz_hashmask; /* (fz_divisor - 1) */ #define FZ_HASHMASK(fz) ((fz)->fz_hashmask) int fz_order; /* Zone order */ u32 fz_mask; #define FZ_MASK(fz) ((fz)->fz_mask) }; |
struct fib_node { struct hlist_node fn_hash; struct list_head fn_alias; u32 fn_key; }; |
struct fib_alias { struct list_head fa_list; struct rcu_head rcu; struct fib_info *fa_info; u8 fa_tos; u8 fa_type; u8 fa_scope; u8 fa_state; }; |
struct fib_info { struct hlist_node fib_hash; struct hlist_node fib_lhash; …… int fib_dead; unsigned fib_flags; int fib_protocol; u32 fib_prefsrc; u32 fib_priority; …… int fib_nhs; struct fib_nh fib_nh[0]; #define fib_dev fib_nh[0].nh_dev }; |
struct fib_nh { struct net_device *nh_dev; struct hlist_node nh_hash; struct fib_info *nh_parent; unsigned nh_flags; unsigned char nh_scope; #ifdef CONFIG_IP_ROUTE_MULTIPATH int nh_weight; int nh_power; #endif #ifdef CONFIG_NET_CLS_ROUTE __u32 nh_tclassid; #endif int nh_oif; u32 nh_gw; }; |
ip rule add from 10.1.1.0/24 table TR1 ip rule add iff eth0 table RT2 |
dst nexthop dev 10.1.0.0/16 10.1.1.1 eth0 10.1.0.0/24 10.1.0.1 eth1 |
dst nexthop dev 10.1.0.0/24 10.1.0.1 eth1 10.1.0.0/24 10.1.0.2 eth1 |
ip route add 10.0.1.0/24 nexthop via 10.0.1.1 weight 1 nexthop via 10.0.1.2 weight 2 table RT3 |
ip addr add 172.16.100.1/24 dev eth1 ip route add default via a.b.c.d dev eth1 |
ip route add 172.16.10.0/24 via e.f.g.h dev eth2 |
echo “250 HS_RT” >> /etc/iproute2/rt_tables |
ip rule add from 192.168.1.0/24 dev eth0 table HS_RT pref 32765 ip route add default via e.f.g.h dev eth2 iptables –t nat –A POSTROUTING –s 192.168.1.0/24 –j MASQUERADE |
ip route flush cache |
通信人家园 (https://www.txrjy.com/) | Powered by C114 |