I wrote it because I had a hard time unexpectedly when I tried to fix the IP address from the terminal by just touching Linux as a hobby.
This time, I set it in a Wi-Fi environment, but I also consider the difference from a wired connection.
――I have no knowledge about networks. Therefore, this article may also have serious mistakes and flaws. --My environment is Zorin OS 15.3. Since it is based on Ubuntu and has a lot in common, I think that it can be set in the same way on Ubuntu. However, it has not been verified. --It can be set relatively easily from the GUI. [Reference link 1](#Reference link) --This time, it is set using a command. ――As I wrote above, the main method is to write the configuration file in a Wi-Fi environment. [Reference links 4, 6](#reference links) is recommended for detailed wired settings.
This is a preparation for fixing the IP address.
1-1. [Check IP address / interface name](# 1-1-Check ip address interface name) 1-2. [Check the address of the default gateway](# 1-2-Check the address of the default gateway) 1-3. [Check DNS address](# 1-3-Check dns address)
What IP address should be fixed? It should be easy to understand. Anything that is not used in other devices will do. You can check what kind of IP address you have now with the following command.
$ ip address
Also check which interface is used. (I don't know how to distinguish it .. It may be the one with more lines than others ..)
By the way, you can also narrow down the output to a specific interface.
$ip address show interface name
You can check it with ʻip route. To output only the default one with
grep`, it is as follows.
$ ip route | grep default
I see a statement that you should refer to /etc/resolv.conf
directly, but this seems to be a mistake. In the first place, this file is generated by systemd-resolved
, and it seems to use systemd-resolved --status
when you want to know the details. [Reference 2](#Reference link)
$ systemd-resolved --status
The number in DNS Servers
in the interface item examined above is the target address.
Create it in / etc / netplan /
. The file name is 99_config.yaml
. It seems that editing the existing XX_config.yaml
is deprecated. [Reference 3,4](#Reference link)
/etc/netplan/99_config.yaml
network:
version: 2
renderer: networkd
wifis:
Interface name:
dhcp4: no
dhcp6: no
addresses:
- 192.168.XXX.XXX/24
gateway4: 192.168.XXX.XXX
nameservers:
addresses:
- 192.168.XXX.XXX
access-points:
"accessPoint1":
password: "password"
"accessPoint2":
password: "password"
Netplan seems to support two backends, networkd and Network Manager. When I was researching, many sites used networkd, but if you use Network Manager, use renderer: NetworkManager
.
The 4th line is wifis:
, but for wired connection, please use ʻethernets:`.
The interface name should be the one in [1-1. Check the IP address / interface name](# 1-1-Check the IP address interface name).
Line 9 -192.168.XXX.XXX/24
should be the IP address you want to fix.
Line 10 gateway4: 192.168.XXX.XXX
should be the one in [1-2. Find the default gateway address](# 1-2-Check the default gateway address).
The -192.168.XXX.XXX
on the 13th linenameservers:
> ʻaddresses:` should be the one in [1-3. Look up DNS addresses](# 1-3-look up dns addresses).
After the 14th line ʻaccess-points:`, only Wi-Fi connection is set. Please note that the access point name (SSID) and password should be enclosed in double quotation marks. You can have one or three or more access points.
It's scary to apply the settings suddenly, so use the netplan try command. After applying the settings temporarily, if the Enter key is not pressed, it will automatically return to the original settings in 120 seconds. You can change it to any number of seconds with the --timeout
option. [Reference 5](#Reference link)
$ sudo netplan try --timeout 180
During this time, reconnect to the network and then try searching the net to see if it connects properly. It is also a good idea to set up another terminal and check with ʻip address` to see if the IP address is actually fixed.
If successful, press Enter and you're done!
Even if it times out, it can be applied with the apply command.
$ sudo netplan apply
In the first place, I had too little knowledge of networks to look up terms, but I had a lot of trouble because the websites that hit the search were old and the methods varied from site to site. First of all, it took time to get to the point of "using Netplan".
When I first wrote 99_config.yaml
, I didn't know the try
command and just ʻapply`. As a result, I was disappointed because I couldn't connect ... I made a mistake in the description, but I didn't notice it at first, so I moved the configuration file, restarted the PC, and did various things. The night before I wrote this, I was depressed, saying, "I have to re-install the OS tomorrow ...", even after correcting the mistake. When I started up my PC this morning, I was happy that the Wi-Fi was connected (although I couldn't fix the IP address), but I was confused because I didn't understand the reason.
After that, when I set it by looking at the Netplan official [(Reference 6)](#Reference link), it succeeded in fixing. After all the formula is great.
Recommended with [Reference 4](#Reference link) for wired and more complicated network environments.
This is a poor article, but thank you for reading to the end.
Recommended Posts