2

I've successfully managed to give ubuntu server 16.04 (Raspberry Pi 3 B) a static ip, but the dynamic ip is still present and active. Using ssh is the only way of accessing the server.

How do i get rid of the dynamic ip?

I have put my static ip configuration in /etc/network/interfaces. The dynamic ip is not defined in /etc/network/interface anymore, it's defined in /etc/network/interfaces.d/*.cfg. I've tried commenting out /etc/network/interfaces.d/*.cfg and the dynamic ip configuration itself, but this is when the problems start kicking in. After sudo shutdown -h now -> replug -> start, the system looses the static ip. I cant even login with the dynamic ip, even though it's visible.

This is little off topic, but i was once logged in with static ip and after installing mysql-server the ssh connection was suddenly cut off and i had to reconnect with the dynamic ip. Seems like the ip addresses aren't treated equally.

Do i need to disable/delete some dhcp client deamons/files and if so, how? The dhcp client seems to go nuts if i try to prevent it from reaching the dhcp configuration by commenting them out.

I've configured a static ip before, but this time everything seems to be working differently.

Here are the requested files

/etc/network/interfaces:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address            192.168.1.201
netmask            255.255.255.0
network            192.168.1.0
broadcast          192.168.1.255
gateway            192.168.1.1
dns-nameservers    62.241.198.245

# Source interfaces
# Please check /etc/network/interfaces.d before changing this file
# as interfaces may have been defined in /etc/network/interfaces.d
# See LP: #1262951

/etc/network/interfaces.d/*.cfg:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
2
  • Kinda hard to work without a copy of your network configurations. You may want to copy/paste a copy here so we can see what you are attempting.
    – Thomas Ward
    Jun 15, 2017 at 11:56
  • Please add complete code of /etc/network/interfaces and other files included in your config to your question.
    – derHugo
    Jun 15, 2017 at 11:58

1 Answer 1

1

Comment out/remove auto eth0 iface eth0 inet dhcp - it is the reason why dynamic IP is being assigned (using DHCP). You shouldn't have the same interface defined twice. See https://help.ubuntu.com/lts/serverguide/network-configuration.html for more details on network configuration.

3
  • Hi michal! I've already tried that, but I did try again because it seems to be the obvious solution to this problem. After commenting auto eth0 iface eth0 inet dhcp and reboot, neither the dynamic ip nor static ip were visible, making it impossible to login. I even tried replacing dhcp with the static ip configuration, but during reboot it gets overwritten by something, leaving only dynamic ip visible. I've already sorta given up, which I dont like to do. I'll configure the static ip on the router so i can carry on with other stuff.
    – Mikey
    Jun 16, 2017 at 17:06
  • @Mikey are you sure you've installed from server iso? If not, you may have NetworkManager messing up your config, you should disable it so all manual configs are preserved. Not sure if it's up-to-date, but you can take a look at this how-to: help.ubuntu.com/community/NetworkConfigurationCommandLine/…
    – michal
    Jun 16, 2017 at 19:01
  • I have installed a preinstalled version of ubuntu server, downloaded from ubuntu-pi-flavour-maker.org/download. I should have mentioned that. The command dpkg --get-selections | grep network-manager returned nothing and servce NetworkManager status gave loaded: not-found (Reason: No such file or directory) Active: inactive (dead). I tried to install from ubuntu server iso, but it doesn't seem to have ssh installed by default. I'm running the server as headless and I'm unable to access it physically. It would be interesting to see how this works with the official version of ubuntu.
    – Mikey
    Jun 17, 2017 at 9:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .