0

I don't understand why I can ping between 10.0.3.* and 192.168.1.* if are in different subnets. I search for it but I don't find any that clarifies it to me. I would appreciate any help, docs, diagrams. Thank you.

This is my ifconfig

lo        Link encap:Bucle local  
          Direc. inet:127.0.0.1  Másc:255.0.0.0
          Dirección inet6: ::1/128 Alcance:Anfitrión
          ACTIVO BUCLE FUNCIONANDO  MTU:65536  Métrica:1


lxcbr0    Link encap:Ethernet  direcciónHW 68:14:01:xx:xx:xx  
          Direc. inet:10.0.3.1  Difus.:10.0.3.255  Másc:255.255.255.0
          Dirección inet6: fe80::883d:xx:xx:xx/64 Alcance:Enlace
          ACTIVO DIFUSIÓN FUNCIONANDO MULTICAST  MTU:1500  Métrica:1


vethB8L38G Link encap:Ethernet  direcciónHW 68:14:01:xx:xx:xx  
          Dirección inet6: fe80::fcb4:xx:xx:xx/64 Alcance:Enlace
          ACTIVO DIFUSIÓN FUNCIONANDO MULTICAST  MTU:1500  Métrica:1


 wlan0     Link encap:Ethernet  direcciónHW 68:14:01:xx:xx:xx  
           Direc. inet:192.168.1.68  Difus.:192.168.1.255  
           Másc:255.255.255.0
           Dirección inet6: fe80::6a14:xx:xx:xx/64 Alcance:Enlace
           ACTIVO DIFUSIÓN FUNCIONANDO MULTICAST  MTU:1500  Métrica:1

And my ip route

default via 192.168.1.1 dev eth0  proto static 
10.0.3.0/24 dev lxcbr0  proto kernel  scope link  src 10.0.3.1 
192.168.1.0/24 dev wlan0  proto kernel  scope link  src 192.168.1.68  metric 9

my LXC container IP 10.0.3.43

1 Answer 1

1

why I can ping between 10.0.3.* and 192.168.1.* if are in different subnets

For the same reason that you can ping the entire Internet, even though it's all in different nets and subnets. There are routers in between, which connect those networks.

Here, your Linux system is acting as a router between the two (because it's connected to both 192.168.1.0/24 and 10.0.3.0/24 networks, and presumably it has IP forwarding enabled in sysctl).


There's another question in there – why you're able to receive replies from 192.168.1.0/24 devices, without having to explicitly tell them which gateway to use for 10.0.3.0/24 addresses.

For that to work, I suspect whatever program configured lxcbr0 also enabled SNAT (masquerading) via iptables – the same kind of NAT as your home router does – so outside hosts think they're being pinged by 192.168.1.68.

1
  • So if I understand, when I ping google.com from container (IP 10.0.3.43) it goes through 10.0.3.1 gateway and from there Linux system act like a router and send it by any network interface to router. 10.0.3.43 --> 10.0.3.1 --> Linux system --> wlan0 --> Router
    – limit2001
    Aug 24, 2018 at 10:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .