AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-445425

Manitoba's questions

Martin Hope
Manitoba
Asked: 2023-06-19 18:08:51 +0800 CST

无法在多个 RPi 之间转发数据包

  • 5

我有一个可以连接互联网的家庭路由器。我还有一台计算机,但无法直接连接到路由器。希望我有两个我不知道该怎么办的树莓派。

在此输入图像描述

我根据@User1686的回答在 PI #1 上运行了以下命令:

    # Set static IP for eth0 interface
    ip addr add 192.168.1.100/24 dev ppp0
    
    # Set static IP for ppp0 interface
    ip addr add 192.168.0.1/24 dev ppp0

    # Enable IP forwarding
    echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
    echo 'net.ipv6.conf.all.forwarding=1' >> /etc/sysctl.conf
    sysctl -p /etc/sysctl.conf

    # Route packets to PI #2
    ip route add 192.168.2.0/24 via 192.168.0.2 dev ppp0

    # Masquerade all outgoing packets with his own IP
    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

并在 PI #2 上运行以下命令:

    # Set static IP for eth0 interface
    ip addr add 192.168.2.1/24 dev eth0
    
    # Set static IP for ppp0 interface
    ip addr add 192.168.0.2/24 dev ppp0

    # Enable IP forwarding
    echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
    echo 'net.ipv6.conf.all.forwarding=1' >> /etc/sysctl.conf
    sysctl -p /etc/sysctl.conf

    # Forward packets to PI #1
    ip route add default via 192.168.0.1
    ip route add 192.168.1.0/24 via 192.168.0.1 dev ppp0

    # Masquerade all outgoing packets with his own IP
    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

我还在计算机上启用了静态 IP 以连接到 PI #2:

    # Set static IP
    ip addr add 192.168.2.100/24 dev eth0

    # Forward packets to PI #2
    ip route add default via 192.168.2.1

    # Add DNS server
    echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolv.conf

我遇到了一些问题,因为我无法从我的计算机访问某些 IP 和互联网。这是我尝试过的快速表格:

命令 圆周率 #1 圆周率#2 电脑 HomeRouter 上的任何设备
平 192.168.0.1 好的 好的 好的 没有
平 192.168.0.2 好的 好的 好的 没有
平 192.168.1.1 好的 好的 好的 好的
ping 192.168.2.1 好的 好的 好的 没有
平 192.168.1.100 好的 好的 好的 好的
平 192.168.2.100 好的 好的 好的 没有
卷曲8.8.8.8 好的 好的 好的 好的
卷曲 google.com 好的 好的 好的 好的

根据@User1686的回答,我的计算机现在能够与我的家庭路由器上的其他设备进行通信,但它们现在能够与我的计算机进行通信(ping 192.168.2.100例如)。

有没有一种方法可以在不编辑路由器配置的情况下路由数据包?

networking
  • 1 个回答
  • 27 Views
Martin Hope
Manitoba
Asked: 2023-05-04 20:11:07 +0800 CST

IP路由连接到本地网络中的每个子网

  • 6

我有一个只有以太网的网络。我不知道某些设备使用的 IP 和子网,因此我无法设置我的计算机以连接到这些设备。我已经使用像 masscan 这样的工具来使用 ARP 创建网络地图,但它需要很长时间(甚至通过以太网将设备直接连接在一起)。

是否可以在不更改 IP 地址和子网的情况下创建 IP 路由以获取本地网络中的所有数据包?

我在想这样的事情:

# Enable packets forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

# Set local IP
ifconfig eth0 192.168.1.0 netmask 255.255.255.0

# Add IP routes for each subnet
ip route add 0.0.1.0/24 via 192.168.1.0
ip route add 0.0.2.0/24 via 192.168.1.0
...
ip route add 10.0.1.0/24 via 192.168.1.0
ip route add 10.0.2.0/24 via 192.168.1.0
...
ip route add 192.168.1.0/24 via 192.168.1.0
...
ip route add 255.255.255.0/24 via 192.168.1.0

那行得通还是我完全误解了它的工作方式?

networking
  • 1 个回答
  • 34 Views
Martin Hope
Manitoba
Asked: 2022-02-08 07:57:12 +0800 CST

将流量重定向到另一个 IP 和端口

  • 5

我有一个带有随机虚拟 IP 的虚拟机。我可以使用以下命令行检索其 IP:

VM_IP=$(some command)

我想得到的是可以像这样重定向我的本地流量的东西:

  • http://MY_MACHINE:8080至http://VM_IP:80
  • https://MY_MACHINE:4443至https://VM_IP:443

我已经尝试过使用 iptables,但是现有条目太多,我不想破坏某些东西。我也启用了net.ipv4.ip_forward.

问题主要是VM_IP可以每天更换一次(因为硬件关闭)。

networking port-forwarding
  • 1 个回答
  • 45 Views
Martin Hope
Manitoba
Asked: 2021-10-02 00:56:49 +0800 CST

GuestAdditions 版本的流浪问题

  • 5

我正在尝试Vagrantfile在我的 Ubuntu 服务器上运行一个。我收到以下错误消息:

An error occurred during installation of VirtualBox Guest Additions 6.1.26. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
Unmounting Virtualbox Guest Additions ISO from: /mnt
Cleaning up downloaded VirtualBox Guest Additions ISO...
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   5.2.0
VBoxService inside the vm claims: 6.1.26
Going on, assuming VBoxService is correct...
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   5.2.0
VBoxService inside the vm claims: 6.1.26
Going on, assuming VBoxService is correct...
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   5.2.0
VBoxService inside the vm claims: 6.1.26
Going on, assuming VBoxService is correct...
Restarting VM to apply changes...

我使用以下命令安装 Virtualbox 和 Vagrant:

# Install VirtualBox
sudo apt-get install linux-headers-$(uname -r) build-essential dkms
sudo apt-get install libgl1-mesa-glx libxmu6 libxt6 -y
sudo apt-get install virtualbox -y

# Install vagrant and its plugins
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - && sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" && sudo apt-get update && sudo apt-get install vagrant -y
vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-disksize
vagrant plugin install vagrant-hostmanager

安装的版本:

Vagrant 2.2.18
Virtualbox 6.1.26

安装卡在:

Installing rsync to the VM...
==> worker-customer: Rsyncing folder: /home/worker/ => /vagrant

这似乎是合乎逻辑的,因为来宾添加无法正常工作。

如何修复版本不匹配?

virtualbox vagrant
  • 1 个回答
  • 334 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve