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
    • 最新
    • 标签
主页 / computer / 问题 / 1456539
Accepted
Thomas Wong
Thomas Wong
Asked: 2019-07-06 06:57:18 +0800 CST2019-07-06 06:57:18 +0800 CST 2019-07-06 06:57:18 +0800 CST

将来自 eth1 的所有流量路由到 tun0 (ssh)

  • 772

我的电脑有两块物理网卡,eth0一个用来上网,eth1一个用作dhcp服务器,让多个无线路由器可以上网。

我启用了内核 ip 转发并使用 iptable 添加了一些规则:

net.ipv4.ip_forward = 1 iptables -A FORWARD -i eth1 -j ACCEPT iptables -A FORWARD -o eth1 -j ACCEPT iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

一切正常。

现在,我想通过隧道传输所有流量eth1(使用SSH_VPNtun0创建的第三个虚拟网络接口)

这是我的 ifconfig 输出:

eth0    Link encap:Ethernet  HWaddr b8:27:eb:dd:56:bb  
        inet addr:10.1.0.212  Bcast:10.1.0.255  Mask:255.255.255.0
        inet6 addr: fe80::ba27:ebff:fedd:56bb/64 Scope:Link
        UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
        RX packets:25131918 errors:0 dropped:0 overruns:0 frame:0
        TX packets:2234134 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000 
        RX bytes:1527934819 (1.5 GB)  TX bytes:342049206 (342.0 MB)

eth1    Link encap:Ethernet  HWaddr 00:0e:c6:b2:60:90  
        inet addr:192.168.50.1  Bcast:192.168.50.255  Mask:255.255.255.0
        inet6 addr: fe80::20e:c6ff:feb2:6090/64 Scope:Link
        UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
        RX packets:1919359 errors:0 dropped:1 overruns:0 frame:0
        TX packets:321412 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:1000 
        RX bytes:135557477 (135.5 MB)  TX bytes:338750947 (338.7 MB)

tun0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
        inet addr:10.11.0.212  P-t-P:10.11.0.226  Mask:255.255.255.255
        UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
        RX packets:8 errors:0 dropped:3 overruns:0 frame:0
        TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
        collisions:0 txqueuelen:500 
        RX bytes:492 (492.0 B)  TX bytes:252 (252.0 B)

我该如何转发?我尝试了几种方法但没有运气:(

提前致谢。

ssh iptables
  • 1 1 个回答
  • 728 Views

1 个回答

  • Voted
  1. Best Answer
    Thomas Wong
    2019-08-02T18:46:25+08:002019-08-02T18:46:25+08:00

    问题是默认路由。

    这是解决方案:

    1. bring up ssh tunnel interface (10.11.0.212)
    2. replace the default route using tunnel interface (10.11.0.1 over 10.1.0.1)
    3. add a route for the tunnel remote to passthrough eth0 gateway (e.g. x.x.x.x via 10.1.0.1)
    4. ip forward for eth1
    
    • 0

相关问题

  • OpenVPN 可以连接,流量有效但我不在本地网络中

  • 如何使用 GUI 远程访问 EC2 控制台

  • 需要 LDAP 身份验证 * 和 * ssh 身份验证

  • 加载密钥“ec256.pem”:尝试从私钥生成公钥时抛出无效格式

  • 为什么 chown 600 id_rsa 修复权限问题?

Sidebar

Stats

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

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

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    Windows 10 服务称为 AarSvc_70f961。它是什么,我该如何禁用它?

    • 2 个回答
  • Marko Smith

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

    • 6 个回答
  • Marko Smith

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

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

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

    • 5 个回答
  • Marko Smith

    ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1056)

    • 4 个回答
  • Marko Smith

    我如何知道 Windows 安装在哪个驱动器上?

    • 6 个回答
  • Martin Hope
    Albin 支持结束后如何激活 WindowsXP? 2019-11-18 03:50:17 +0800 CST
  • Martin Hope
    fixer1234 “HTTPS Everywhere”仍然相关吗? 2019-10-27 18:06:25 +0800 CST
  • Martin Hope
    Kagaratsch Windows 10 删除大量小文件的速度非常慢。有什么办法可以加快速度吗? 2019-09-23 06:05:43 +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
    Inter Sys Ctrl+C 和 Ctrl+V 是如何工作的? 2019-05-15 02:51:21 +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