I tried setting up a static ip on my ubuntu 16.04 system using this guide

so I bought a network card since my motherboard's ethernet port is broken but when i enter sudo nano /etc/network/interfaces to input the new info, the card doesn't show up althought it does when I enter ifconfig. As you can see the card is connected to the internet and working properly;enter image description here

I also tried inputting the ports to see what would happen with the desired static ip's and all, but my connection would only work for a second. Any ideas how to fix this? thanks!

update: I was unable to set a static ip with my router because of some dns issue, so i hooked my pc up directly to the modem (which is also a router) and using what @G_G posted i was able to set my desired ip

  • Did you restart the network service after inputting the static ip information? Also, can you show the information that you put in their itself? – Nasir Riley May 8 '18 at 1:41
  • # interfaces(5) file used by ifup(8) and ifdown(8) auto lo enp1s0f0 enp1s0f1 iface lo inet loopback iface enp1s0f0 inet static address netmask gateway iface enp1s0f1 inet static address netmask gateway dns-nameservers – paranormal brotivity May 8 '18 at 2:45
  • i only restarted my router but not my modem, not sure if i should've done both @NasirRiley sorry if the layout of the last comment is messy, i can't figure out how to make it pretty. – paranormal brotivity May 8 '18 at 2:51

The name of the card does not have to show up under /etc/network/interfaces, you can just enter it manually. Once the boot process sees a 1:1 match between a name in your interfaces file, and an actual interface, it will then apply the configuration. Here's a very basic stanza, obviously, replace the interface's names, with your own. Either If down/up, or reboot.

auto eth0
iface eth0 inet static

You can also set a static IP "on the fly" from bash, using this command, it will not however, survive a reboot.

sudo ifconfig eth0 netmask 

and then add a default route

sudo route add default gw eth0

again, don't forget to swap "eth0" with the actual name of your interface.

  • Thanks for the answer ill give it a try but i have some questions: Is the line iface lo inet loopback which appears under auto lo eth0 important or can i remove i? Also can I assign the same ip address for 2 ports, since my network card has 2? – paranormal brotivity May 8 '18 at 3:12
  • forgot to mention you, @G_G – paranormal brotivity May 8 '18 at 3:15
  • Leave the loopback setup as it is, it is a logical interface used by the OS. You can have multiple IP addresses, but only one should have the "gateway" definition, otherwise, you'll have to configure a bit more complex routing definitions. – G_G May 8 '18 at 13:20
  • After playing around with it, my network card shows up, with the desired ip address but no internet connection. I get a Dns_probe_finished_no_internet error do i have to specify a dns server? im gonna try bypassing the router, connecting it directly to the modem to see if it works – paranormal brotivity May 9 '18 at 1:01
  • Place your DNS address in /etc/resolv.conf, e.g "name server". You can also ping (Google's DNS server), to see if you have internet, but having a DNS issue. Meaning you can reach the internet via direct IP, but having a name resolution issue. – G_G May 9 '18 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.