代码改变世界

Ubuntu 桥接设置 (在ubantu 18.04.5 之前好用 ,,,,18.04.5 就不好用了)

2020-09-02 14:56  握瑾怀瑜  阅读(427)  评论(0编辑  收藏  举报

1 安装vmware (如果不安装 不能直接在ubantu的terminal界面进行复制)

点击虚拟机  点击 安装vmware tools

2 安装 openssh-server (如果不安装  xshell无法连接)会提示如下信息

安装openssh-server。

命令如下:sudo apt-get install openssh-server

================================================================

上述步骤完成后 进行桥接设置

步骤一  修改此文件  下面是修改后的样子 cat /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto ens33
iface ens33 inet static
address 192.168.3.78
gateway 192.168.3.1
netmask 255.255.255.0
dnsserver 8.8.8.8

步骤二  修改此文件  下面是修改后的样子  cat /etc/resolv.conf

# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
nameserver 114.114.114.114
nameserver 8.8.8.8
options edns0

步骤三 重启网络

/etc/init.d/networking restart

 

 

 步骤四 查看ip

ifconfig

 

步骤五 ping网络 看是否ping同

ping www.baidu.com    ping外网

ping 192.168.3.237   ping内网

 

切记   /etc/resolv.conf文件中 一定加上 nameserver 8.8.8.8
不然出现ping百度ping不通

 

root@songbin-virtual-machine:/osm# vim /etc/resolv.conf
root@songbin-virtual-machine:/osm# cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 8.8.8.8
nameserver 127.0.0.53
options edns0

成功