Set static IP on Ubuntu Core
Thanks to @MrShunz and @chili555 in the comments. These are the settings that worked for me:
Subnet: 192.168.1.0/24
Address: 192.168.1.101
Gateway: 192.168.1.1
Name servers: 8.8.8.8
tsteiner
Updated on September 18, 2022Comments
-
tsteiner over 1 year
I'm new to Ubuntu Core. On first login I selected the option: Will use DHCP for IPv4
Now I'd like to change my machine to use a static IP to be easier to log in remotely.
I ran
sudo console-conf
on the machine (over ssh, if relevant). This gives me the option to selectUse a static IPv4 configuration
, which I do.This gives me the fields
subnet
,address
, gateway,
name servers, and
search domains`. What should I set for these fields? I would like my IP address to be 192.168.1.101. It is currently 192.168.1.13 from DHCP. My chosen IP address is pretty arbitrary, but I'm going to have a group of computers that I'd like to have the IP addresses 192.168.1.1XX.I'm used to setting my subnet to
255.255.255.0
, but I get the error message:should be in CIDR form (xx.xx.xx.xx/yy)
. I'm not sure what this means or how to fix it. When I try adding/24
at the end of the subnet, the error message goes away and I get a new error message:'192.168.1.101' is not contained in '255.255.255.0/24'
.-
Daniele Santi over 5 yearsWelcome to AskUbuntu!
CIDR
notation is used for the IP address, not the netmask, have you tried192.168.1.101/24
? -
tsteiner over 5 yearsThanks @MrShunz. I tried adding the CIDR to the IP address but it won't let me type in the
/
character. I attached a screenshot of the error message, in case it helps anyone. -
chili555 over 5 yearsFor the subnet, please try:
192.168.1.0/24
Reference: askubuntu.com/questions/1015632/… -
Andrew about 4 yearsJust to clarify the solution that was given. The mistake is that subnet 192.168.x.x/x is being confused with the subnet mask (usually 255.255.255.0). A quick explanation is that the ip4 address including the cidr (the number after /) tells us what the mask should be and so can be omitted. So for the point of completeness, a bit of light reading can be found at en.wikipedia.org/wiki/Subnetwork if you want a deeper dive into IPv4 subnetting.
-
LeonidMew about 4 yearsI advice to configure dhcp on router so it give preferred ip based on mac, if that possible in router settings
-
-
deej about 5 yearsThanks for your answer, I kept trying 255.255.255.0/24 instead of 192.168.1.0/24
-
Artur Meinild about 3 yearsThere are pros and cons about setting static IP in gateway. I believe the OP was after a way to set it in Ubuntu itself.