linux 路由内核,Linux中ip包路由时,什么样的被认为是local的?

你的理解基本上正确,其实很简单的说法就是,linux收到包之后就查路由表,如果找到match的规则就做相应的操作,对需要送到本地的包也是有路由规则的,如下面的例子,列出了local table里边的路有规则

debian:~# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0C:29:8C:7C:3F

inet addr:10.1.24.210  Bcast:10.1.24.255  Mask:255.255.255.0

inet6 addr: fe80::20c:29ff:fe8c:7c3f/64 Scope:Link

UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

RX packets:2397 errors:0 dropped:0 overruns:0 frame:0

TX packets:2165 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:208932 (204.0 KiB)  TX bytes:370468 (361.7 KiB)

Interrupt:169 Base address:0x1400

eth1      Link encap:Ethernet  HWaddr 00:0C:29:8C:7C:49

inet addr:192.168.0.1  Bcast:192.168.0.255  Mask:255.255.255.0

inet6 addr: fe80::20c:29ff:fe8c:7c49/64 Scope:Link

UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:6 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:0 (0.0 b)  TX bytes:468 (468.0 b)

Interrupt:177 Base address:0x1480

lo        Link encap:Local Loopback

inet addr:127.0.0.1  Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING  MTU:16436  Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

debian:~# ip route show table local

broadcast 192.168.0.255 dev eth1  proto kernel  scope link  src 192.168.0.1

broadcast 10.1.24.0 dev eth0  proto kernel  scope link  src 10.1.24.210

broadcast 127.255.255.255 dev lo  proto kernel  scope link  src 127.0.0.1

local 10.1.24.210 dev eth0  proto kernel  scope host  src 10.1.24.210

local 192.168.0.1 dev eth1  proto kernel  scope host  src 192.168.0.1

broadcast 192.168.0.0 dev eth1  proto kernel  scope link  src 192.168.0.1

broadcast 10.1.24.255 dev eth0  proto kernel  scope link  src 10.1.24.210

broadcast 127.0.0.0 dev lo  proto kernel  scope link  src 127.0.0.1

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

【 在 xly1030 (polestar) 的大作中提到: 】

: 现在有这样一个实验:两台linux主机,其中一台(M)上有两个网卡,两个IP分别为A:10.66.0.182  B:192.168.100.100,另一台(N)上只有一个网卡,IP为C:10.66.0.149。在N上增加这样一条路由:

: route add -net 192.168.100.0/24 gw 192.168.0.182

: 然后ping 192.168.100.100是可以ping通的,在M上并没有打开ip_forward。

: ...................

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值