Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure DNS in Ubuntu system

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to configure DNS in Ubuntu system". In daily operation, I believe many people have doubts about how to configure DNS in Ubuntu system. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to configure DNS in Ubuntu system". Next, please follow the editor to study!

After studying Ubuntu DNS for a long time, you may encounter network problems in Ubuntu DNS. Here we will introduce the solution of Ubuntu DNS to network problems. Ubuntu is newly installed. Although the graphical interface is clearly set up for ip, gateway, etc., but you can't surf the Internet.

A friend warned that maybe it's the setting. Try the command line setting. So I searched for how to set it up, and it was really successful. The details are as follows:

1. To verify that it can be connected, use the ping command ping gateway to always start with a realistic unreachable

two。 Set IP sudo ifconfig eth0 133.133.190 netmask 255.255.255.0 so that even if the IP address and subnet mask of the network card eth0 are set

3. Set the gateway sudo route add default gw 133.133.133.40

4. Ping gateway can be connected with ping.

5. Set Ubuntu DNS modification / etc/resolv.conf to add to it

Address 1 of nameserver DNS

Address 2 of nameserver DNS is complete. After this setting, it seems that the IP will change again the next time it is turned on.

Use the command to set the ip address of Ubuntu

1. Set IP sudo ifconfig eth0 203.171.239.155 netmask 255.255.255.224 so that even if the IP address and subnet mask of the network card eth0 are set

two。 Set the gateway sudo route add default gw 203.171.239.129

3. Set DNS to modify / etc/resolv.conf, and address 2 of the address 1 nameserver DNS that is added to the nameserver DNS is completed. However, after this setting, it seems that IP will no longer exist the next time it is turned on.

Second, directly modify the system configuration file

The network configuration file for Ubuntu is: / etc/network/interfaces

Ubuntu command line modify network configuration method / etc/network/interfaces after opening, you can set DHCP or manually set static ip. Front auto eth0, let the network card boot and mount automatically.

1. Configure the network card in DHCP mode

Edit the file / etc/network/interfaces:sudo vi / etc/network/interfaces. And replace the line about eth0 with the following line:

# The primary network interface-use DHCP to find our address auto eth0 iface eth0 inet dhcp

Use the following command to make the network settings take effect: sudo / etc/init.d/networking restart can also enter the following command directly from the command line to get the address sudo dhclient eth0

two。 Configure a static IP address for the network card

Edit the file / etc/network/interfaces:sudo vi / etc/network/interfaces. And replace the line about eth0 with the following line: # The primary network interface

Auto eth0 iface eth0 inet static address 192.168.3.90 gateway 192.168.3.1 netmask 255.255.255.0 # network 192.168.3.0 # broadcast 192.168.3.255

Change the above ip address and other information to yourself. Use the following command to make the network settings effective: sudo / etc/init.d/networking restart

3. Set the second IP address (virtual IP address)

Edit the file / etc/network/interfaces:sudo vi / etc/network/interfaces. Add the following line to the file:

Auto eth0:1 iface eth0:1 inet static address 192.168.1.60 netmask 255.255.255.0 network x.x.x.x broadcast x.x.x.x gateway x.x.x.x

Fill in all the information such as address,netmask,network,broadcast and gateways according to your situation. Use the following command to make the network settings effective: sudo / etc/init.d/networking restart

4. Set host name (hostname)

Use the following command to view the host name of the current host: sudo / bin/hostname

Use the following command to set the host name of the current host: sudo / bin/hostname newname

When the system boots, it reads the name of the host from / etc/hostname.

For more information about setting the host name, please visit here

5. Configure Ubuntu DNS

First, you can add some host names and IP addresses corresponding to these host names in / etc/hosts, which is a simple native static query. To access the Ubuntu DNS server for query, you need to set up the / etc/resolv.conf file. Assuming that the IP address of the Ubuntu DNS server is 192.168.3.2, the content of the / etc/resolv.conf file should be:

Search test.com

Nameserver 192.168.3.2

/ etc/network/interfaces

After opening it, you can set DHCP or manually set static ip. Front auto eth0, let the network card boot and mount automatically.

1. Configure the network card in DHCP mode

Edit the file / etc/network/interfaces:sudo vi / etc/network/interfaces and replace the line about eth0 with the following line:

# The primary network interface-use DHCP to find our address auto eth0 iface eth0 inet dhcp

Use the following command to make the network settings take effect: sudo / etc/init.d/networking restart can also enter the following command directly from the command line to get the address sudo dhclient eth0

two。 Configure a static IP address for the network card

Edit the file / etc/network/interfaces:sudo vi / etc/network/interfaces

And replace the line about eth0 with the following line: # The primary network interface

Auto eth0 iface eth0 inet static address 192.168.3.90 gateway 192.168.3.1 netmask 255.255.255.0 # network 192.168.3.0 # broadcast 192.168.3.255

Change the above ip address and other information to yourself. Use the following command to make the network settings effective: sudo / etc/init.d/networking restart

3. Set the second IP address (virtual IP address)

Edit the file / etc/network/interfaces:sudo vi / etc/network/interfaces to add the following line to the file:

Auto eth0:1 iface eth0:1 inet static address 192.168.1.60 netmask 255.255.255.0 network x.x.x.x broadcast x.x.x.x gateway x.x.x.x

Fill in all the information such as address,netmask,network,broadcast and gateways according to your situation. Use the following command to make the network settings effective: sudo / etc/init.d/networking restart

4. Set host name (hostname)

Use the following command to view the host name of the current host: sudo / bin/hostname

Use the following command to set the host name of the current host: sudo / bin/hostname newname

When the system boots, it reads the name of the host from / etc/hostname. For more information about setting the host name, please visit here

5. Configure Ubuntu DNS

First, you can add some host names and IP addresses corresponding to these host names in / etc/hosts, which is a simple native static query. To access the Ubuntu DNS server for query, you need to set up the / etc/resolv.conf file. Assuming that the IP address of the Ubuntu DNS server is 192.168.3.2, the content of the / etc/resolv.conf file should be:

Search test.com nameserver 192.168.3.2

To solve the problem of Ubuntu restart Ubuntu DNS reset author: wynlchae release date: 2008-4-09 View number: 256from: http://www.linuxdiyf.com sets static IP under Ubuntu, "main menu", "system", "system Management", "Network", delete the original Ubuntu DNS in "Ubuntu DNS" and fill in the static Ubuntu DNS server, but it will be restored after restart, and the next boot will have to be reset again.

Backup first: sudo cp / etc/resolv.conf / etc/resolv.conf.bak and then edit sudo gvim / etc/dhcp3/dhclient.conf to add the following line to the end, that is, the two servers of Ubuntu DNS, prepend domain-name-servers 208.67.222.222208.67.220.220 *, fill in these two servers according to their own Ubuntu DNS.

At this point, the study on "how to configure DNS in Ubuntu system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

  • How RK3288 modifies the browser's default home page and bookmarks

    This article mainly introduces RK3288 how to modify the browser default home page and bookmarks, the article is very detailed, has a certain reference value, interested friends must read it! Modify the browser default home page:

    © 2024 shulou.com SLNews company. All rights reserved.

    12
    Report