Ceci est une ancienne révision du document !
When you install Ubuntu, it covers a lot of bases for you that older Linux distros never used to. Oh, I recall trying to get my very first 3G dongle running in Aarvark, or the PCMCIA one in Warty Warthog. PPP was just not installed in Warty if I remember correctly. It took a moment to get me sorted, but the ‘happy ever after’ was that it worked! I recall trying to use a number of other distros, including Knoppix – the then defacto distro you used if you had odd hardware, and it just was not working with my no-name (ISP Branded) hardware. This was where my respect for Ubuntu started. Don’t get me wrong, I used Ubuntu, before it was Ubuntu, and though it was great, it was still a bit sucky when it came to hardware support. Luckily, I was semi-salted with network knowledge, so things were not such a mystery to me. This is what I want to impart to Ubuntu n00bs in this issue. A few issues ago we looked at ‘ip r’. Today, I want to take the next step in that direction as all you n00bs have obviously mastered ip r. So when I type ip r, I don’t need to explain.
This time around, let us look at ‘route’. Consider the screenshot bottom left.
Now this is a VM, but if I had metal with a modem, there would be another interface under ‘Iface’
Note that ‘ip r’ and ‘ip r list’ will net you the same result.
Here is a quick hands-on, please set your ‘network’ settings in Firefox to use Cloudflare for encrypted DNS (shown bottom right).
Once done, open a terminal and type: ip r get 1.1.1.1 and press enter. 1.1.1.1 is Cloudflare DNS, so you should get a result. What you just did is: you asked ip route to get you a packet going to 1.1.1.1 and tell you what route it was taking (shown top right).
In my case, we can see a packet going there via the 10.0.2.2 network on device enpos3, the source was 10.0.2.15 (my VM), and the uid was 1000. Just like roads, you cannot simply hop on say, the N1, and drive straight to the supermarket. The supermarket may be located in Cherry Lane. To get to Cherry Lane, you need to turn right at Trent Road (don’t try, it is all fictitious). The same goes for your IP traffic. To get to 1.1.1.1 in Cherry Lane, I need to take a right at 10.0.2.2. This is the route that the IP traffic will take. Should you have more than one network interface, you can play traffic cop and route traffic all on your lonesome. You could now add a way for all traffic going to the 1.1.1.0 network to use enp1s3 for instance, with a simple command: ip r add 1.1.1.0/24 dev enp1s3 (*don’t do this, it is an example for you to understand the syntax, you will need to understand subnetting before attempting this). Anyway, once you do this, all traffic to 1.1.1.1 will now travel on enp1s3 instead of enp0s3. Typing ip route now, you will see that entry added. If you added this fake route to your machine, you can remove it with the same command, using del instead of add.
Consider the next replacement (bottom left).
In this case, the n’s are not the same. In the newer ip command, n is the shortest I can make neighbour. In the old way, the n stood for numeric. It is not needed for our example, but I wanted you to see the difference (just typing arp would imply –vn). Since the ‘new’ way is a lot like IOS, you could type ip ne, or ip nei, and the command will still work. The same syntax happens here, you can type ip nei add 192.168.1.250….. (you would need the MAC address or link-layer address aka lladdr, etc… too much detail for a n00b, just know it can be done). Because this is possible, it is also possible for an attacker to add their own ‘neighbour’ here, known as arp cache poisoning. These are reasons you never use root, unlike Windows – where people use Administrator and don’t learn. And just like that, in two issues, your understanding of the ip command doubled.
To understand all the twists and turns your computer packets make, I wanted you to type traceroute www.google.co.uk in your terminal, but that is also not available in 22.04, so I will cover that in another issue. :) The Linux landscape is changing, and you need to change with it, I suppose. I should have planned this better, but I see it as an opportunity to write about another funky tool soon!
As always, send recipes to misc@fullcirclemagazine.org