Just what I needed - thanks! I'm familiar with IP itself, but I was always a bit hazy about the Unix-style routing tables. The explanation that it searches for the longest match was particularly helpful.
Excellent...I always stuck in routing.. But this is really fantastic explanation and exactly what I was looking for.appreciate if you show routing for multi.nic configured server.
Thanks a lot Steven. I've set up the same network but with "netplan" tool (I'm using Ubuntu 22.04). Now PCs from different networks see each other (ping goes fine) and next time I'll connect Kali Linux to start its tools and learn ethical hacking
It would also work if you on the server or client removed the default router and added an new to the router instead. That is the default route on the server is change from 10.0.2.2 to 192.168.2.2. It will use the router for all transmissions out on the internet from the server, instead of using the 10.0.2.2. To test routing, try the command tracepath(1) or traceroute(1) and you will see which routers will be used between the current computer and destination.
Nice video, thanks. Would be nice to see how the router itself was set up. You said it was another Linux VM? You somehow used VirtualBox to attach two network interfaces to it and manually set up the routes?
I am currently working on a lab environment "tap0" interface. When I type the command route, my "tap0" interface is not showing a default gateway address. How do I find the router on this network?
For this small network you could use 192.168.1.0/24. However I used 192.168.0.0/16 as in the future I plan to have network with three chained subnets, e.g. 192.168.1.0 connected to 192.168.2.0 connected to 192.168.3.0. Then a route on 192.168.3.1 could be designed as: "To reach any other subnet in 192.168.0.0/16, send to gateway 192.168.2.1". This route would cover reaching subnets 192.168.2.0 and 192.168.3.0 (I would need to add two separate route entries, just use the one generic entry). So in summary, in this demo 192.168.0.0/16 was not necessary, but I used it because I was thinking ahead to future scenarios of using virtual networks in VirtualBox. I should have explained that more in the video.
Might I suggest that you try out the command ipcalc(1) to get more information. $ ipcalc 192.168.0.0/16 Address: 192.168.0.0 11000000.10101000. 00000000.00000000 Netmask: 255.255.0.0 = 16 11111111.11111111. 00000000.00000000 Wildcard: 0.0.255.255 00000000.00000000. 11111111.11111111 => Network: 192.168.0.0/16 11000000.10101000. 00000000.00000000 HostMin: 192.168.0.1 11000000.10101000. 00000000.00000001 HostMax: 192.168.255.254 11000000.10101000. 11111111.11111110 Broadcast: 192.168.255.255 11000000.10101000. 11111111.11111111 Hosts/Net: 65534 Class C, Private Internet So here you see that the first two byte is network, so that is used to decide if a machine address is on the same network or not. So, /24 is the usual size, as it give a network with place for 253 machines, and /16 will get you 2^¹⁶ -2 addresses. If you have many /24 networks, you can collect them under the same router direction. So 192.168.0.0/16 will be a route for all networks that start with 192.168.0.0, for example 192.168.0.0/24, and 192.168.1.0/24 etc up to 192.168.255.0/24.