Score:0

Change IPv4 address of my server

th flag

I've tried to change de IPv4 address from my Ubuntu Server but when i run the command "netplan apply" an error appear, the error appeared is telling me my gateway isn't a valid IPv4 Address. Someone can help me please. I'm a beginner with servers. I know this is a such idiot thing but i realy have difficult to do that IP migration. Tnx for the patient guys.
(Sorry for my Bad English i'm from Brazil.)
The yaml file is:

network:
  version: "2"
  ethernets:
    ens160:
      dhcp4: false
      addresses: 
      -190.115.196.57/26
      gateway4: 190.115.196.1/26
      nameservers:
        addresses: [8.8.8.8, 4.2.2.4]
      routes:
      - to: 51.161.15.254/32
        via: 0.0.0.0
        scope: link

The IP of the router is: 51.161.15.254

David avatar
cn flag
What is the IP address of your router?
Gabriel Celestino avatar
th flag
I consulted the ip of router and the ip is 51.161.15.254
David avatar
cn flag
Please edit the question and add this info. It is important that the question has all the details. Where did the IP you are using for gateway come from?
David avatar
cn flag
Are you sure that the 26 and 32 at the end of the IP addresses is the correct value? Generally speaking, /32 means that the network has only a single IPv4 address and all traffic will go directly between the device with that IPv4 address and the default gateway. The device would not be able to communicate with other devices on the local subnet.
Gabriel Celestino avatar
th flag
Yes, about this is correctly and propositaly, this is a server running from a rented machine localized in another space where other machines are disponibilized to other people, the unic access open from this server is the SSH access or by the dashboard of provider, i requested a migration for the provider and they sent the IP to configure at the serve. I'm started questioning about the IP whose the provider sent me.
Gabriel Celestino avatar
th flag
Thanks @David you're correctly, i removed the /26 from the mask and that worked :) Thank u men, for the patient and to help me to resolve my problemn
David avatar
cn flag
The 26 from the gateway line is the one you removed?
Gabriel Celestino avatar
th flag
Yes, the gateway line
David avatar
cn flag
OK I will make an actual answer and you can accept it.
Score:0
cn flag

In this case the /26 at the end of the IP address was causing that address to be evaluated by a number of bits.

A “/26” network provides 64 IP 4 addresses. This was interpenetrated by netplan apply as an invalid address.

By not having the /26 the address is seen as a normal IP 4 address.

So in summary, and in non-CS degree terms, the slash notation tells us how many bits are used in that address (we can't change), and ultimately what is left for us to assign out specifically.

Without the /26 the gateway works as expected.

I am sure there could be a far more tech answer but I think this should suffice.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.