1

I am frustrated beyond belief, at this point. I have a simple task of changing an ip from DHCP to static, but it does not want to accept the new address. The interfaces file looks like this:

source /etc/network/interfaces.d/*

auto lo enp3s0

iface lo inet loopback

iface enp3s0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.254
nameserver 192.168.1.5

When I perform sudo ifdown enp3s0 && ifup enp3s0, it continues to get 192.168.1.200. dhclient is not running and network-manager is uninstalled. I can't figure out where this ip is coming from.

Update:

After banging my head against the wall, for a couple more hours, I settled on this, as the configuration file:

auto lo
iface lo inet loopback

auto enp3s0
iface enp3s0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.254
dns-nameservers 192.168.1.5
dns-search ***.com

I also created a static record in the DHCP server, for the MAC address of this interface, even though this interface is outside the record of the DHCP server. Once I did all that, I rebooted the server and the 1.2 address stuck. Not sure which process cured the issue. I know, after changing the file and restarting the service, nothing changed. It was either the reboot or some combination of the 3.

talkinggoat
  • 99
  • 1
  • 4
  • 11
  • Have you confirmed that the address 192.168.1.2 is outside the DHCP pool in the router or other access point and that there is therefor no possible collision? The proper term is dns-nameservers; not nameserver. What is the exact result of: sudo ifdown enp3s0 && sudo ifup -v enp3s0? – chili555 May 26 '17 at 21:51
  • First off, you have enp3s0 twice... once as auto, again as static. Second, your gateway doesn't look correct... I'd expect something more like 192.168.1.0, and your nameserver should be dns-nameservers (as chili555 points out)... and do you have your own local network DNS server at .5? Why not use the GUI to set a manual address? See https://askubuntu.com/questions/143819/how-do-i-configure-my-static-dns-in-interfaces for an example. – heynnema May 27 '17 at 16:43
  • @heynnema There's nothing wrong with auto lo enp3s0 - That just indicates which interfaces should be brought up when ifup -a is run. The iface stanza dictates how it should be brought up. See man 5 interfaces – muru May 29 '17 at 11:34
  • 1
    If you do sudo ifdown enp3s0 && ifup enp3s0, the ifup command is not run with sudo! – fkraiem May 29 '17 at 11:39
  • DHCP range is 1.100-1.200. Gateway should be the default gateway and point to a device. In our case, 1.254. 1.0 is the reserved address, for the subnet.

    @fkraiem, sorry, that was a typo. I was putting sudo.

    – talkinggoat May 29 '17 at 14:50

1 Answers1

1

Ok, your interfaces file is messed up.

# Source a directory for other configuration
source /etc/network/interfaces.d/*

# The loopback network interface
auto lo  
iface lo inet loopback

# The primary network interface
auto enp3s0  
iface enp3s0 inet static  
address 192.168.1.2  
netmask 255.255.255.0  
gateway 192.168.1.254  
dns-nameservers 192.168.1.5

That's how it should look like. Adjust your /etc/network/interfaces with the above and restart your networking with sudo systemctl restart networking.service and everything should be set-up correctly.

Ziazis
  • 2,174
  • Now, my interfaces file looks like this: auto lo iface lo inet loopback auto enp3s0 iface enp3s0 inet static address 192.168.1.2 netmask 255.255.255.0 gateway 192.168.1.254 I moved the nameserver to resolv.conf. Ran ifdown enp3s0 && ifup enp3s0 I checked to make sure dhclient was not running... root@ubuntu-host:/etc/network# ps -e | grep dhclient root@ubuntu-host:/etc/network# Also, that Network-manager was not installed. root@ubuntu-host:/root# dpkg --get-selections | grep network-manager root@ubuntu-host:/root# – talkinggoat May 29 '17 at 20:22
  • You should edit your question with that information really hard to read in a comment. But writing into the resolv.conf won't help you since it will be overwritten. Is there still a problem with your IP I can't read it out from your comment? Also you should use systemd to restart your networks. sudo systemctl restart networking.service – Ziazis May 30 '17 at 06:20