Hello, couple years ago, I wanted to set and have a static IP, but due lack of knowledge I can't have it. Now I manage to set it and it's kinda work. Here are some methods I'm using.
I start with netplan. For netplan I just need to make this configuration :
network:
wifis:
YOUR_WIRELESS_INTERFACE:
dhcp4: no
dhcp6: no
addresses:
- x.x.x.x/24
routes:
- to: default
via: x.x.x.x
access-points:
"YOUR_SSID":
password: "YOUR_PASSWORD"
version: 2
renderer: networkd
We just need to set the dhcp{4,6} off and assingn the address (for me it's 192.168.x.x) and its gateway (192.168.1.1).
Besides netplan, we can use ifupdown as well. It gives me old debian memories to be honest. We just need to edit /etc/network/interfaces
.
This is my simple /etc/network/interfaces
file :
auto wlp3s0
iface wlp3s0 inet static
wpa-conf /etc/wpa_supplicant-wlp3s0.conf
address x.x.x.x
gateway 192.168.1.1
dns-nameservers 8.8.8.8 1.1.1.1
The address and gateway are still same. By the way I also use wpa_supplicant instead of other helper.
For the last method, I use systemd-networkd. It's quite simple to configure it. All we need is a single file at /etc/systemd/network/
, I call it 11-wlp3s0.network
.
The configuration looks like this :
[Match]
Name=wlp3s0
Unmanaged=no
[Network]
Address=192.168.x.x/24
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=1.1.1.1
It's kinda same, we need to assign wireless interface (for me it's wlp3s0), address, gateway, etc. Don't forget enable and start the systemd-networkd's service !
sudo systemctl enable systemd-networkd
sudo systemctl start systemd-networkd