UFW 解除主机到访客流量的阻断

UFW 解除主机到访客流量的阻断

我在 Ubuntu 20.04 上,并且已启用 UFW 作为终止开关以与我的 wireguard vpn 配合使用。我当前的规则运行正常,只是我的 ubuntu 主机和 debian 10.5 virtualbox 客户机之间的流量被阻止了。

我如何解除对主机/访客流量的阻拦?

我当前的 UFW 规则是:

[ 1] 22/tcp                     ALLOW IN    Anywhere                  
[ 2] Anywhere                   ALLOW OUT   Anywhere on wg-client1     (out)
[ 3] 80/tcp                     ALLOW IN    Anywhere                  
[ 4] 443/tcp                    ALLOW IN    Anywhere                  
[ 5] Anywhere on wg-client1     ALLOW IN    Anywhere                  
[ 6] 94.121.83.88               ALLOW OUT   Anywhere                   (out)
[ 7] 21/tcp                     ALLOW IN    Anywhere                  
[ 8] 53                         ALLOW OUT   Anywhere                   (out)
[ 9] 9418/tcp                   ALLOW IN    Anywhere                  

我之前尝试过以下操作但都失败了(例如,当我 ping 客户机 ip192.168.0.84 时,我得到了ping: sendmsg: Operation not permitted

[10] 22/tcp                     ALLOW IN    10.10.10.2                
[11] 22/tcp                     ALLOW IN    192.168.0.0/24            
[12] Anywhere                   ALLOW IN    192.168.0.0/24            
[13] 192.168.0.0/24             ALLOW IN    Anywhere                  
[14] 192.168.0.0/24 22          ALLOW IN    Anywhere                  
[15] Anywhere                   ALLOW IN    192.168.0.0/24 22 

我还使用伪装将所有流量通过 VPN。我的ifconfig -a输出是:

enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.18  netmask 255.255.255.0  broadcast 192.168.0.255
        ether b4:a9:fc:b0:b0:d1  txqueuelen 1000  (Ethernet)
        RX packets 668474  bytes 477052588 (477.0 MB)
        RX errors 0  dropped 1  overruns 0  frame 0
        TX packets 945227  bytes 553827446 (553.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2106  bytes 198789 (198.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2106  bytes 198789 (198.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vboxnet0: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 0a:00:27:00:00:00  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vboxnet1: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 0a:00:27:00:00:01  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wg-client1: flags=209<UP,POINTOPOINT,RUNNING,NOARP>  mtu 1420
        inet 10.10.10.2  netmask 255.255.255.255  destination 10.10.10.2
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
        RX packets 565766  bytes 350115976 (350.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 451704  bytes 440547648 (440.5 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp0s10f2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.6  netmask 255.255.255.0  broadcast 192.168.0.255
        ether 34:cf:f6:61:c0:38  txqueuelen 1000  (Ethernet)
        RX packets 433847  bytes 102427035 (102.4 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 94319  bytes 29872001 (29.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

需要注意的是,我的 debian 客户机有两个网络接口,1 个静态 192.168.0.84 和 1 个动态,以便我可以使用多个 wifi 网络。

# The primary network interface
auto enp0s3
iface enp0s3 inet static
        address 192.168.0.84
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
       
#dynamic gateway for Internet access on random networks
auto enp0s8
iface enp0s8 inet dhcp

谢谢

更新 我终于弄清楚了我的系统日志并注意到了这一点:
[UFW BLOCK] IN= OUT=wlp0s10f2 SRC=192.168.0.255 DST=192.168.0.84 ....

因此,我当然检查了 vbox 管理器,对于我的桥接连接适配器,我只有 2 个选项:wlp0s10f2enp3s0(以太网)

尽管ifocnfig -a显示wg-client1为网络接口,但我在 VirtualBox 中没有wg-client1可用的接口。

我尝试了不同的规则来允许 22/tcp wlp0s10f2wg-client1但是没有成功。

有小费吗?

答案1

有点尴尬,但在开始赏金后不到 5 分钟,我就根据有根据的猜测解决了这个问题:

sudo ufw allow out on wlp0s10f2 from any to 192.168.0.84

现在我的全新安装完美运行。我的错误是使用 vpn ip 作为出站地址。将其更改为 vbox 机器的 ip 地址。让我回到正轨。

相关内容