-1

I have the following problem. First of all. Here are my interfaces.

# ip addr
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever

2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
    inet 10.10.1.15/24 brd 10.10.1.255 scope global eth1
    inet6 fe80::a00:27ff:fe28:b0c4/64 scope link
       valid_lft forever preferred_lft forever

As you can see the loopback interface serves following network 127.0.0.1/8, the network mask is 255.0.0.0.

My problem is that I need to route all traffic for example for the network 127.22.0.0/16 to the interface eth1.

I have following routes now

default via 10.10.1.2 dev eth1
default via 10.10.1.2 dev eth1  metric 203
10.10.1.0/24 dev eth1  scope link
10.10.1.0/24 dev eth1  proto kernel  scope link  src 10.10.1.15  metric 203
10.10.1.2 dev eth1  scope link

And I try to add the following route

ip route add 127.22.0.0/16 via 10.10.1.2 dev eth1

But unfortunately it doesn't work.

Here is the output

root@sys:/ # ip route flush cache
ip route flush cache
root@sys:/ # ip route get "127.22.0.1"
ip route get "127.22.0.1"
local 127.22.0.1 dev lo  src 127.0.0.1
    cache <local>

As you can see all packets are still redirected to loopback.

What is the best solution for that problem ?

closed as off-topic by Tero Kilkanen, Jenny D, Paul Haldane, yagmoth555, 030 May 16 '17 at 10:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow." – Tero Kilkanen, Jenny D, Paul Haldane, yagmoth555, 030
If this question can be reworded to fit the rules in the help center, please edit the question.

4

As mentioned in What is the rest of the 127.0.0.0/8 address space used for? , the 127.0.0.0/8 block is the loopback block, and all packets destined to the block must be looped back to the origin host.

So, you cannot route those packets anywhere.

  • Thanks for the answer, there is no really way to fix this somehow ? Kernel module, iptables, somehow, I really need it. – e109848 May 5 '17 at 12:18
  • 1
    I think you actual problem is something different and you are hunting a XY problem. Why do you need to route 127.22.0.0/16? Any service or machine you want to reach? – Thomas May 5 '17 at 12:31
  • @Thomas , the problem that there is no way to change 127.22.0.0, third party software forces to use it, and on windows it works fine. – e109848 May 5 '17 at 14:10
  • 2
    You might be able to change kernel behavior by building your own custom version of the kernel that changes how the lo interface works. However, you really need to know what you are doing to make this happen. Your 3rd party software is something very weird when it is doing things like that. – Tero Kilkanen May 5 '17 at 14:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.