传出网络被阻止(不是防火墙),传入连接正常

传出网络被阻止(不是防火墙),传入连接正常

我觉得安装 pihole在我的 ubuntu 18.04 服务器上安装 pihole 来屏蔽家庭网络的广告。但是当我这样做时,所有网络都停止了。所以我卸载了 pihole删除推荐的目录在服务器上(然后重新启动)。

所以我的系统现在没有 pihole 的概念,我可以通过 SSH 和 VNC(GUI)进入服务器,但是什么都无法出去。

网络(ifconfig)输出如下所示:

ens4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1460
    inet 10.152.0.2  netmask 255.255.255.255  broadcast 0.0.0.0
    inet6 fe80::4001:aaf:fe98:2  prefixlen 64  scopeid 0x20<link>
    ether 42:01:0a:98:01:02  txqueuelen 1000  (Ethernet)
    RX packets 52675  bytes 4336857 (4.3 MB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 83573  bytes 66763505 (66.7 MB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

我注意到广播设置为 0.0.0.0,应该这样设置吗?该网络上的其他机器将其设置为与内部 IP 相同。这是我的防火墙(ufw)规则。 该链接实际上是出现此问题的服务器:)

的输出/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
options edns0
search google.internal

另外要注意的一点是 /etc/network/interfaces 的输出是:

# ifupdown has been replaced by netplan(5) on this system.  See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
#    sudo apt install ifupdown

(不确定这是否相关)

答案1

编辑/etc/resolv.conf只是一种短期解决方案,并非持久的解决方案。解决方案是编辑/etc/netplan/50-cloud-init.yaml并粘贴以下内容:

network:
    version: 2
    ethernets:
        ens4:
            dhcp4: true
            nameservers:
                addresses: [1.1.1.1, 8.8.8.8]
            set-name: ens4

编辑此 YAML 文件时,请确保使用 4 个空格,而不是制表符。然后运行sudo netplan apply以保存更改。

资料来源:瑞克媒体linux化

相关内容