cancel
Showing results for 
Search instead for 
Did you mean: 

Assigning static IP to Ubuntu Server

FIXED
djack
Newbie
Posts: 4
Thanks: 1
Registered: ‎25-02-2021

Assigning static IP to Ubuntu Server

I am at my wits ends here...

 

I had Ubuntu Server 20.04LTS running perfectly with a 192 ip address allocated by the router. I have now switched to trying to use a static IP for remote login outside my LAN and, although the settings are accepted and the syntax is all correct in the yaml files for Netplan, I can't connect to anything via ping.

I see the failure to resolve error, but even when I try and ping an IP rather than a .com address I still get a failure.

Has anybody got any experience with this?

10 REPLIES 10
corringham
All Star
Posts: 722
Thanks: 365
Fixes: 9
Registered: ‎25-09-2015

Re: Assigning static IP to Ubuntu Server

There's not enough info here to understand quite what the problem is.

When you say you have changed to use a static IP is that for the Ubuntu server?

If so have you changed the Server to use a static IP, or changed the router to always allocate the same IP to the server?

Is the server's static IP a local IP address (192.) or a externally visible IP allocated by Plusnet?

Where are you pinging from - inside your LAN or from an external address?

What router do you use?

I have lots more questions, but that's a start...

I have run servers for years, so it is possible to get it working - it's just a matter of finding your problem.

djack
Newbie
Posts: 4
Thanks: 1
Registered: ‎25-02-2021

Re: Assigning static IP to Ubuntu Server

Many thanks Corringham.

 

I requested a static IP address for the Ubuntu server so that I could access it remotely when I am travelling for work.

 

I have changed the Server to use a static IP. My understanding was that the router can't allocate an external static ip to a device. The changes have been made in the yaml file of the Netplan directory in Ubuntu Server 20.04.

 

The server's static IP is an externally visible ip allocated by Plusnet and begins 212.

 

I am pinging from inside the LAN from the server itself. For example, I'm testing ping google.com

 

I use a BT SmartHub 2 router.

 

Many, many thanks for taking the time to try and help me.

MisterW
Superuser
Superuser
Posts: 11,414
Thanks: 3,568
Fixes: 273
Registered: ‎30-07-2007

Re: Assigning static IP to Ubuntu Server

I requested a static IP address for the Ubuntu server

@djack assuming what you mean is that you requested a static IP from PlusNet . This static IP will be allocated to your router and not a device on your network. In order to access your server from outside the network, you need to allocate it either a static or fixed IP on the local network ( 192.168.... ) and then set up port forwarding on the router to forward the remote access ports to the server IP.

Superusers are not staff, but they do have a direct line of communication into the business in order to raise issues, concerns and feedback from the community.

dvorak
Moderator
Moderator
Posts: 28,520
Thanks: 6,306
Fixes: 1,459
Registered: ‎11-01-2008

Re: Assigning static IP to Ubuntu Server

I think you're misunderstanding something, you need to get a static ip address on your router for public ip and then a private static ip address for your server.

<-internet->router<-local lan->server

you can request a static ip address from PN if you haven't already.
switch the server config back to dhcp.
then in the homehub find the server and change the setting to 'always use this ip' to on, this is a defacto static ip.
then set up port forwarding rules for the ports you want open on your server.
or you can put the server in the dmz, but that has inherent security risks.
Customer / Moderator
If it helped click the thumb
If it fixed it click 'This fixed my problem'
corringham
All Star
Posts: 722
Thanks: 365
Fixes: 9
Registered: ‎25-09-2015

Re: Assigning static IP to Ubuntu Server

Fix

Ok, the way this should work is as follows:

  • the router has the external address allocated by Plusnet
  • the server should use an internal address (192.) - that can be set up statically in the server, or can be a reserved DHCP address allocated by the router. I prefer the second approach, as it keeps all the address settings in one place (you don't want the router allocating the same address to some other device)
  • you should set port forwarding in the router for the services you want the server to handle to point to the server's IP (you could put the server in the DMZ, but that exposes all ports of your server to the outside world)
  • you may need to set an option for address loop back if you want to use your external static address to access you server from within the LAN (I'd have to look up your router to know whether that is needed or how to do it)

I've not used Netplan, so I can't really help with that.

djack
Newbie
Posts: 4
Thanks: 1
Registered: ‎25-02-2021

Re: Assigning static IP to Ubuntu Server

I am so grateful to you all for taking the time to help a stranger. This has worked.

 

When I looked at applying for a static IP address so I could access my server remotely, I remember reading something along the lines of "we will only let you have a static IP address if your needs can't be met through port forwarding". I took that to mean that static IPs and port forwarding were mutually exclusive; i.e., port forwarding was used INSTEAD of a static IP. As ever with these things, one small assumption caused me a whole heap of pain.

 

I reset the Ubuntu Server to use the 192 address (and for the router to keep it the same) and then set up port forwarding.

 

On one hand, I'm kicking myself that I didn't come to this forum sooner. Having said that, I still learned a lot about Ubuntu through all of my failed attempts to get it work myself. I know it must be frustrating for experts when newbies come on here asking daft questions, but I would rather have a go and learn and, maybe, be able to help others one day too.

You can all consider yourselves good samaritans today!

 

Thanks again. 

corringham
All Star
Posts: 722
Thanks: 365
Fixes: 9
Registered: ‎25-09-2015

Re: Assigning static IP to Ubuntu Server

It's great that you have it working!

One thing I recommend for anyone that exposes ports to the world is to go to https://www.grc.com/shieldsup and do a scan of your IP address or domain name  (if you have one). Run the "All service ports" scan to check that only the ports you expect to be externally visible are.

MisterW
Superuser
Superuser
Posts: 11,414
Thanks: 3,568
Fixes: 273
Registered: ‎30-07-2007

Re: Assigning static IP to Ubuntu Server

I remember reading something along the lines of "we will only let you have a static IP address if your needs can't be met through port forwarding"

I think you'll find that relates to the provision of a block of public IP addresses. It's something that was available in the past (probably only to business accounts) but was severely rationed due to the lack of IPV4 addresses. The standard PlusNet supplied router never supported multiple public IP's anyway!!, you needed to provide your own router that was capable of supporting a 'public routed subnet'. A single static IP has always (well up to now anyway!) been available , free on business accounts and a one-off £5 on residential.

Superusers are not staff, but they do have a direct line of communication into the business in order to raise issues, concerns and feedback from the community.

djack
Newbie
Posts: 4
Thanks: 1
Registered: ‎25-02-2021

Re: Assigning static IP to Ubuntu Server

Thanks for the tip. Shields Up is showing me to be ultra-secure with the VPN on (which is cheating I guess). With the VPN off - so properly targeting my IP - it can identify the server, a secured music library and the Samba port. 

 

I will make a point of reading up on all this to educate myself. Thanks again.

Townman
Superuser
Superuser
Posts: 20,146
Thanks: 8,212
Fixes: 104
Registered: ‎22-08-2007

Re: Assigning static IP to Ubuntu Server

Hi dJack,

A warm welcome to the forums.


@djack wrote:

I know it must be frustrating for experts when newbies come on here asking daft questions, but I would rather have a go and learn and, maybe, be able to help others one day too.

 


Nah!!  What is frustrating is when people do not heed good advice or do not come back to say "That worked for me" and may be "Thank you!".  The latter is satisfying for those who have given their time to help, whilst the former is helpful to other seeking solutions to the same or similar problems.  Together, that is how this community flourishes.

There is no such thing as a "daft" question if you do not know what you do not know ... but there can be "daft" answers!

Hope you will stick around!

Superusers are not staff, but they do have a direct line of communication into the business in order to raise issues, concerns and feedback from the community.