I'm sshing to a raspberry pi over wlan0 and trying to connect to a modem at the ethernet interface.
Take a look at my table and my ip route get:
lz@raspberrypi:~ $ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.33.1 0.0.0.0 UG 600 0 0 wlan0
192.168.1.1 0.0.0.0 255.255.255.255 UH 10 0 0 eth0
192.168.33.0 0.0.0.0 255.255.255.0 U 600 0 0 wlan0
lz@raspberrypi:~ $ ip route get 192.168.1.1
local 192.168.1.1 dev lo src 192.168.1.1 uid 1000
cache local
No matter what I tried, it always goes through the loopback interface.
ifconfig output:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::____________ prefixlen 64 scopeid 0x20<link>
ether ____________ txqueuelen 1000 (Ethernet)
RX packets 346 bytes 15916 (15.5 KiB)
RX errors 1 dropped 346 overruns 0 frame 0
TX packets 113 bytes 13414 (13.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
I also tried cross interface:
cat /proc/sys/net/ipv4/ip_forward
1
network interfaces
$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source /etc/network/interfaces.d/*
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
Why the route always end up on the loopback?
192.168.1.1
belongs to the Pi. When you connect to it from within the Pi, this happens.192.168.1.1
.