Set static IP on Ubuntu Core

102,201

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

Screenshot

Share:
102,201
tsteiner
Author by

tsteiner

Updated on September 18, 2022

Comments

  • tsteiner
    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 select Use a static IPv4 configuration, which I do.

    This gives me the fields subnet, address, gateway,name servers, andsearch 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'.

    Update: Here is a screenshot of the error messages

    • Daniele Santi
      Daniele Santi over 5 years
      Welcome to AskUbuntu! CIDR notation is used for the IP address, not the netmask, have you tried 192.168.1.101/24?
    • tsteiner
      tsteiner over 5 years
      Thanks @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
      chili555 over 5 years
      For the subnet, please try: 192.168.1.0/24 Reference: askubuntu.com/questions/1015632/…
    • Andrew
      Andrew about 4 years
      Just 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
      LeonidMew about 4 years
      I advice to configure dhcp on router so it give preferred ip based on mac, if that possible in router settings
  • deej
    deej about 5 years
    Thanks for your answer, I kept trying 255.255.255.0/24 instead of 192.168.1.0/24
  • Artur Meinild
    Artur Meinild about 3 years
    There are pros and cons about setting static IP in gateway. I believe the OP was after a way to set it in Ubuntu itself.