Ceci est une ancienne révision du document !
Welcome back to another edition of FCM! This issue, we will look at something I have put off personally, and if you did too, it is time to sit down with the Ubuntu n00bs.
Honestly, I should have moved forward, but muscle memory…
Yes, I still use net-tools, even if it is deprecated. I don’t want to have the net-tools package chat with you; instead, I want us to look at the more modern network tools that ship with Ubuntu. Rather those that ship with any modern Linux distribution.
Just like the hostname and hostnamectl commands confuse n00bs, I suppose the network commands in Ubuntu can be confusing to some, especially when you do not use them that often. On the other side of the coin, you may have old farts like me who are just more comfortable with the older commands, and do not have need for the newer ones. What I do love about the newer commands is that you can use the abbreviated forms like in CISCO IOS.
We can start with ip. Type: man ip - to me please. Here you can see that the command is broken into three sections, with help.
Now if you did not know about the shortcuts, the ip command does seem like a lot of typing, for instance here is the TL;DR page:
Who in their right mind would want to type out: ip –brief address ?? OK, we have established that I am lazy, but no more lazy than the next person – who could not be bothered using Windows or Mac online with all its spying. Oh wait, that is most people. Anyway, the point I am trying to make is that when you see the commands that are more like stories instead of commands, which are you more likely to type?
Consider: ifconfig eth0 down vs ip link set eth0 down
It is already two words more. That is two more things to remember, and you have to remember that, if you leave out ‘set’, it will not work. Now that I have explained my past reluctance in using the new way of doing things, let me show you around, or should I say, “stay a while and listen…”
While I am not as old as Horadric, I feel that way using old Linux commands, so let’s shoot the breeze.
Type: ‘ip address’ and press enter in your terminal. Now type ‘ip a’ and press enter. What is the difference in the output? So, even though we are typing two words, to do what one word used to do, we can shorten it to four keystrokes. Here we go, not wasting my precious time gets them bonus points. Though I did say it was like CISCO IOS, I meant superficially. For instance, we have ‘ip route’ and ‘ip rule’. In CISCO IOS, you need to type until the command is unique. Typing: ‘ip r’ would give you an error. In Ubuntu, typing ‘ip r’ is ‘ip route’. Just be aware of this difference if you have used something like CISCO IOS before.
Now, even though this is great, there is a trap here. Consider the image below.
This is great once you are salted, but when learning, this is cryptic. WTH is “l ls”? It is even worse when the font is horrible, another reason I implore you to use nerd fonts. The command is: ‘ip link ls up’, which tells us which adapters are up. This is great in things like firewalls or servers, where you have more than one interface, but you may not use it at home much. As you can see from my example, the loopback interface, which is always up, is listed with my network interface in the vm, enp0s3. (You may see eth1). This will come with practice, and you should not try to remember all the shortcuts. For now, type ip link, and challenge yourself to shorten it next month, after you have used it this month. We know ‘ls’ is list, so de-constructing the command is not hard. This is my advice for anything, if you can do it backwards, you know it. Yes, I mean that literally.
Looking back at the man page, we will see: ip, options, object, command. Which means I can do something like this: ip a add 192.168.1.100 dev enp0s3 – Now while that may look like gibberish to an Ubuntu n00b, it will most certainly work if your network interface is named enp0s3, like mine is. I can change my IP address with this command, but as soon as I reboot my VM, it will be back to default. Remember this, so if you are following along and you typed it, and your VM’s network connection is gone, and you are unsure how to fix it, know that it is temporary. Logic tells me that if I have an add, I must have a remove. Want to venture a guess on how to “remove” the ip address you just gave your virtual adapter? Nope, it is not rem, remove nor r, it is del for delete. Recall that r is route here. This is what I want you to take away here – type out the full commands now, as a n00b, and in a month or two’s time, when you shorten them, you have a grasp as to why you are doing it one way and not another.
Let’s quickly look at the output I have, and I will point out another thing you may need.
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 08:00:27:b4:a6:6f brd ff:ff:ff:ff:ff:ff
If you do not know much about networking, that is fine, but you may run into a situation where you have a faster or slower line than the average, and your ISP support agent may want you to change the mtu. This is your packet size (Maximum Transmission Unit) that your card transmits. Say you are out in the bundu’s, and you have some wireless connection, your ISP may ask you to lower your mtu. Just like before, we can use the man page (ip, options, object, command) to change it. I would type ip l set mtu 1100 dev enp0s3 • That is ip link (as we will be fiddling with the link) • The set command – as we will set something, in our case, the mtu • The new value • And lastly the device we wish to act upon.
If all this made sense to you, great! If not, please go ahead and play with the ip command. If you would like me to broaden this penny tour, let us know at misc@fullcirclemagazine.org