VM15 Ubuntu18.04 fixed IP

Enter su into the root user to modify the contents of the documents provided the following rights

1. Check your own card Name: Enter the command:

ifconfig -a

or

 ip link

or

ip addr

So my name card: ens33

2. Enter the following command

vi /etc/network/interfaces

3. After opening the file, press the "i" key to enter the edit mode, as shown in FIG configuration:

Explain: (1) a first ring part is disposed multicast address do not cares

          (2) Part II:

      auto name card (NIC first step to see my name is ens33 the same below)

   "Iface ens33 inet static" set a static IP, dynamic, static is to modify the dhcp, if set to a dynamic IP virtual network adapter can not be set

   ip address Sets address setting you want, whether that is consistent with the best IP network segment of the machine are not connected to the Internet easily.

   netmask The subnet mask is consistent with the host

   gateway gateway in a virtual machine on top of the toolbar to select "Edit" and then select "Virtual Network Editor."

    

     dns-nameservers DNS settings may coincide with a host may be provided to a general DNS gateway address 8.8.8.8 or 114.114.114.114

          (3) query the host IP address, subnet mask, gateway

               Press the "window" key + "R", the input "cmd", and then enter the command "ipconfig", carriage return, look down, appears as shown:

        

That network segment where the top three (192.168.1.x), x setting you want

4. After editing, press the "Esc" to exit edit mode, enter ": wq" (! Oh colon) to save and exit

5. Restart the server

/etc/init.d/networking restart

6. When OK to restart the server after success, to see if the fixed IP Success: Enter your first step is to see if the command successfully fixed IP, IP address, and if you set the same success that is fixed

7.ping www.baidu.com

:出现重启服务器ping不通百度的解决办法:一般按上述过程可成功ping通,如若还是不行,可以查看是否与主机IP段一致,还是不行的可以如下解决:

  

 

(1)关闭虚拟机然后单击虚拟机,出现主页点击“编辑虚拟机设置”

    

    设置网络适配器,在“网络连接”处选择“自定义”,再选择“VMnet8(NET)”

  

(2)设置DNS

vi /etc/systemd/resolved.conf

  如图添加DNS地址

 然后保存并退出,重启服务器,再次ping尝试

这样设置DNS,在虚拟机重启后会出现重置,所以需要每次重新设置或者如下设置:

解决Ubuntu 解决重启后resolv.conf重置的问题:

    在网卡配置文件(即第二步输入“vi /etc/network/interfaces”命令打开的文件)里添加下段代码

dns-search foo.org bar.com 

至于为什么这样可以参考

https://blog.csdn.net/lell3538/article/details/50642548

 

 

以上是我对Ubuntu配置固定IP的办法希望能帮到你,我也是小白一枚,有错误也请指正。

 

Guess you like

Origin www.cnblogs.com/Monster-su/p/12431793.html