Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting static IP on Ubuntu Server 12.04 makes loss of external connection

Tags:

static

ubuntu

ip

I have a problem with static IP under Ubuntu 12.04.

With DHCP I have no problem, but when I set (under /etc/network/interfaces) the static address, the gateway, the subnetmask and the dns-nameservers, I have that the Server cannot connect to external world.

It is able only to connect to local IP hosts.

I have tried to insert the nameservers in the /etc/resolv.conf but every time I restart the machine, the changes are canceled.

What could be the problem?

like image 775
frakorn Avatar asked Jun 06 '12 19:06

frakorn


People also ask

How do I set a static ip to Ubuntu Server 20.04 LTS?

The best possible way to set a static IP address to your Ubuntu 20.04 device is to use DHCP reservation. DHCP reservation is a feature built-in to most routers and allows you to set a specific IP. Basically, this feature ensures that the router keeps the IP address aside and only hands it to your device.

How do I set a static IP address on Ubuntu 21.04 Server?

Step #02: Configure static ip address on Ubuntu 21.04 server. Open netplan config file using any editor. Then insert all below lines into your file. or you can edit your old text and replace interface and ip address as like you want. Then save press Esc type :wq then press Enter.

How do I set a static ip in Ubuntu 18.04 terminal?

In the Activities screen, search for “network” and click on the Network icon. This will open the GNOME Network configuration settings. Click on the cog icon. In “IPV4” Method" section, select “Manual” and enter your static IP address, Netmask and Gateway.


1 Answers

Ubuntu 12.04 use resolvconf (a set of scripts and hooks) instead of resolv.conf to manage DNS server. The most notable difference for the user is that any change manually done to /etc/resolv.conf will be lost as it gets overwritten next time something triggers resolvconf.

To add the static dns entries in resolv.conf file,edit /etc/resolvconf/resolv.conf.d/base:

Add these lines (the example below is OpenDNS’s public name servers):

nameserver 208.67.222.222
nameserver 208.67.220.220

Run this command to refresh the resolvconf setting:

sudo service resolvconf restart

To view your DNS Servers addresses, use this command:

cat /etc/resolv.conf
like image 93
Munyua Avatar answered Sep 18 '22 19:09

Munyua