ip route show中src关键字

The src attribute is a hint that is used by the address selection algorithm. It is significant when a host has multiple IP addresses, which is usually, but not always, when it has multiple interfaces. While there are other rules that influence address selection, and a network application can also override the selection algorithm by using system calls like bind(), the src attribute is a way to use a routing-table lookup to answer the question, "If I want to initiate a connection to host X, which of my addresses should I use?"  Here is an example to illustrate the use and effect of the src attribute. To make the point that this is related to addresses and routes, not strictly to interfaces, this example host has only one network interface but two addresses. Furthermore, both addresses are on the same subnet to emphasize the fact that there is no other obvious way to choose which one to use.

$ ip -4 addr show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 10.1.0.2/24 brd 10.1.0.255 scope global eth0
    inet 10.1.0.16/24 scope global secondary eth0
$ ip route list dev eth0
10.1.0.32/27  scope link  src 10.1.0.16
10.1.0.0/24  proto kernel  scope link  src 10.1.0.2

This host can communicate with any of the other 252 addresses on this /24 subnet from either address, but by default it will use 10.1.0.16 when initiating a connection with 10.1.0.32 through 10.1.0.63, and use 10.1.0.2 for all the rest.

If the host is responding, rather than initiating, then it will respond from the destination address of the request. For example, if another host at 10.1.0.32 connects to this host at 10.1.0.2, the response will come from 10.1.0.2 even though that doesn't match the src attribute of the return route.


原文: http://serverfault.com/questions/451601/ip-route-show-src-field


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值