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 static IP for Ubuntu

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces Ubuntu how to configure static IP, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Execute the command:

The code is as follows:

Vim / etc/network/interfaces

The editing content is as follows:

The code is as follows:

Auto lo

Iface lo inet loopback

# configuration of Nic eth0

Auto eth0

Iface eth0 inet static

Address 192.168.1.30 # is set to static IP

Netmask 255.255.255.0

Gateway 192.168.1.1

# dns-nameservers 8.8.8.8

# network 192.168.1.0

# broadcast 192.168.1.255

# the last two are the network number and the broadcast number, which can be calculated by other information, so there is no need to set

# where dns-nameservers is used to specify dns if it is modified as follows / etc/resolv.conf will be reset every time it boots up

# can be used to remove the # and use the dns setting here

Restart takes effect

The code is as follows:

Sudo / etc/init.d/networking restart

If you can't surf the Internet, it could be a dns problem.

The code is as follows:

Sudo vim / etc/resolv.conf

Just set up nameserver 8.8.8.8

If it's not a root account, add sudo.

Yesterday, I set up static IP, but when I turned on my computer today, I found that the server could not connect to the Internet. It was strange. Later, I wondered if I didn't set up DNS, so I used the vi editor to open / etc/resolv.conf:

The code is as follows:

Vi / etc/resolv.conf

Add DNS:

The code is as follows:

Search mydomain.com

Nameserver 61.139.39.73

Nameserver 61.139.2.69

After the configuration is complete, restart the network:

The code is as follows:

/ etc/init.d/networking restart

The problem arises. After restarting the computer, the DNS written in / etc/resolv.conf is cleared again.

Solution.

Write DNS in the / etc/resolvconf/resolv.conf.d/head file.

The code is as follows:

Vi / etc/resolvconf/resolv.conf.d/head

Add DNS:

The code is as follows:

Search mydomain.com

Nameserver 61.139.39.73

Nameserver 61.139.2.69

After the configuration is complete, restart the network:

The code is as follows:

/ etc/init.d/networking restart

Thank you for reading this article carefully. I hope the article "how to configure static IP in Ubuntu" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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

Wechat

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

12
Report