标签: forwarding

iptables 问题:将端口 x 转发到网络上不同机器的 ssh 端口

我有一台 Ubuntu PC,带有两个网卡,充当路由器。一张网卡eth0连接到互联网,另一张eth1连接到局域网。我想将 LAN 中不同主机的 ssh 端口暴露给外部世界的不同端口号。即“ssh user@router -p 1234”应该转到host1的ssh端口,“ssh user@router -p 3456”应该ssh到host2。我为 host1 添加了以下 iptable 规则,但它不起作用:

iptables -A FORWARD -i $EXTIF -o $INTIF -p tcp --dport 1234 -m conntrack --ctstate NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A PREROUTING -t nat -p tcp -d $EXTIP --dport 1234 -m conntrack --ctstate NEW,ESTABLISHED,RELATED -j DNAT --to-destination 10.9.0.2:22
Run Code Online (Sandbox Code Playgroud)

EXTIF是外部接口(eth0),INTIF是内部接口(eth1),EXTIP是eth0的IP地址。

有什么帮助吗?(不确定问题是否清楚,如果有人理解我的意图,请使用正确的行话进行编辑)

ubuntu ssh forwarding

3
推荐指数
1
解决办法
2441
查看次数

阻止 ssh 远程转发端口的 iptables 规则

我正在尝试设置一个 iptables 规则,该规则将阻止通过 ssh 本地远程转发连接访问 ssh 远程转发连接。所以,爱荷华州:

客户端 A 连接到服务器:
ssh -R 10000:localhost:23 someserver

客户端 B 连接到服务器:
ssh -L 23:localhost:10000 某个服务器

我无法让 iptables 阻止这个。在某些 sshd_config 设置无法覆盖的情况下,我需要转发(我将有一个程序专门分发客户端可以转发的端口,希望该程序随后会添加一个 iptables 规则以允许这样做)。

我试过了:

iptables --flush

iptables -A 输入 -i lo -p tcp --dport 0:1024 -j 接受
iptables -A 输出 -o lo -p tcp --dport 0:1024 -j 接受
iptables --policy INPUT DROP
iptables --policy 输出下降

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

iptables -A …

ssh iptables forwarding

3
推荐指数
1
解决办法
5256
查看次数

如何将 UDP 流量从一个公共 IP (linux) 路由到另一个公共 IP (Windows)

我想阻止直接访问我的 Windows 计算机,并希望通过我的 Linux 计算机(同样可以通过公共 IP 访问)公开在其上运行的一些程序。

有没有一种方法可以配置我的 Linux 机器(比如 IP = ),将其在特定端口(比如 )获得的a.b.c.d)所有流量路由到我的 Windows 机器(比如 IP = )的端口?UDP6667e.f.g.h6668

是的,我该如何实施呢?

更新

# bindadress    bindport  connectaddress  connectport

192.168.2.45    6667    192.168.2.104   6668

# logging information
logfile /var/log/rinetd.log

# uncomment the following line if you want web-server style logfile format
logcommon
~          
Run Code Online (Sandbox Code Playgroud)

更新

UDP只想路由流量。

ip route forwarding linux-networking

3
推荐指数
1
解决办法
2万
查看次数

iptables 将传入的 ipv4 流量转发到 ipv6

我是 iptables 的新手,我对它的配置感到迷茫和困惑。我有 IPv4 和 IPv6 连接的工作服务器和只有 IPv6 连接的家庭服务器。

如何设置将所有传入 IPv4 流量、端口 5600 从工作服务器转发到我的家庭服务器(IPv6 地址)、端口 5600 的规则?

ubuntu iptables forwarding

3
推荐指数
1
解决办法
2137
查看次数

Postfix 作为 gmail 的电子邮件转发器,SPF 问题

我正在尝试将 postfix 配置为转发到 gmail。我已经成功地为我托管的域配置了虚拟别名,并且我想重定向,但是 Gmail SPF 验证由于这个原因而失败:

Delivered-To: realrcpt@gmail.com
Received: by 10.25.28.147 with SMTP id c141csp88155lfc;
    Sat, 11 Oct 2014 09:08:40 -0700 (PDT)
X-Received: by 10.224.70.83 with SMTP id c19mr21300511qaj.66.1413043720159;
    Sat, 11 Oct 2014 09:08:40 -0700 (PDT)
Return-Path: <realsender@gmail.com>
Received: from mail1.mycompany.com (mail1.mycompany.com. [2604:xxxxxxx:b5c8])
    by mx.google.com with ESMTP id d63si16549011qgd.80.2014.10.11.09.08.39
    for <realrcpt@gmail.com>;
    Sat, 11 Oct 2014 09:08:40 -0700 (PDT)
Received-SPF: softfail (google.com: domain of transitioning realsender@gmail.com does not designate 2604:xxxxxxx:b5c8 as permitted sender) client-ip=2604:180:2:2cf::b5c
Run Code Online (Sandbox Code Playgroud)

我认为问题在于返回路径。当与另一个主机(例如 namecheap)进行电子邮件转发时,会自动重写为:

Return-Path: <SRS0+BJjl=7C=gmail.com=realsender@eforward3e.registrar-servers.com>
Run Code Online (Sandbox Code Playgroud)

有没有办法在 postfix …

postfix spf forwarding

3
推荐指数
1
解决办法
3243
查看次数

使用端口转发到另一台机器访问远程 PostgreSQL 服务器

我尝试访问运行 PostgreSQL的Server_A。该服务器位于本地网络上,这就是为什么我必须从可访问且位于同一网络中的Server_B转发端口。

要访问Server_B上的 postgreSQl ,我可以轻松地转发这样的端口:

ssh -L 54320:Server_A:5432 user@Server_B
Run Code Online (Sandbox Code Playgroud)

而在另一个终端:

psql -p 54320 -d db_name -U user
Run Code Online (Sandbox Code Playgroud)

我的问题是我想重现从Server_B网络中存在的机器完成的连接。这台机器可以使用以下命令将自己连接到数据库:

psql -h Server_A -p 5432 -d db_name -U user
Run Code Online (Sandbox Code Playgroud)

我实际上有问题:

我无法使用 ssh 命令转发 5432 端口:

通过插入5432:Server_A:5432ssh 命令来转发 5432 端口,我有这个错误:

psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)

我无法解析主机名:

而是直接向前从港口的SERVER_A,我尝试着从港口SERVER_B-h在参数psql …

postgresql networking ssh port-forwarding forwarding

3
推荐指数
1
解决办法
1万
查看次数

根据本地端口,通过不同的公共 IP 在 Squid 中进行代理转发

我希望通过不同的公共 IP 转发持久性 HTTP 请求。它连接到服务器并在服务器持续传输数据时保持连接。

这需要对应用程序透明;路由逻辑需要仅限于建立到目标端口号(或主机:端口)的 HTTP 连接。

我正在考虑让 Squid 服务侦听 LAN IP 但侦听多个端口;如果应用程序连接到端口 A,则通过 nic A 转发请求;对于端口 B 连接,通过网卡 B 转发;等等。

这是 Squid 合适的任务吗?我在哪里可以找到有关配置的一些提示?我在阅读 Squid 文档时迷失了与此相关的任何内容(特别是如何映射本地端口-> 不同的输出 NIC)。

proxy ip squid forwarding

2
推荐指数
1
解决办法
5786
查看次数

邮件转发服务器

有什么办法可以“中继”邮件流量?为了更好地解释,假设将中继邮件的服务器是 10.0.0.1,包含邮件的正确邮件服务器是 Gmail,有什么办法可以让邮件客户端连接到 10.0.0.1,但发送所有流量到 Gmail?这是因为在我有的情况下,我只能直接连接到这个服务器,不能直接连接到互联网,所以要使用邮件,我必须转发/中继它。

有什么办法可以做到这一点,如果可以,怎么办?

email linux forwarding

2
推荐指数
1
解决办法
123
查看次数

服务器拒绝转发连接:管理禁止。同时使用 @IP 和 PermitOpen

[本机为192.168.80.125]

允许所有基本访问的普通 SSH 规则:

AllowUsers                  user1
PubkeyAuthentication        yes
PasswordAuthentication      no
AllowTcpForwarding          yes
UsePAM                      no
Run Code Online (Sandbox Code Playgroud)

匹配组测试

AllowUsers                  user2@IP1 user2@IP2 user2@IP3 user2@IP4
PubkeyAuthentication        yes
PasswordAuthentication      yes
AllowTcpForwarding          yes
    PermitOpen              192.168.80.100:80
    PermitOpen              192.168.80.125:443
AllowAgentForwarding        no
Run Code Online (Sandbox Code Playgroud)

当我以 user2 身份从 IP1 连接到 sshd 时,我可以使用 PuTTY 打开隧道:

本地S:IP1:8080 远程D:192.168.80.100:80

本地源:IP1:8443 远程目标:192.168.80.125:443

我打开浏览器并浏览到 localhost:8080 我得到连接重置。我打开浏览器并浏览到 localhost:8443 我得到连接重置。

我检查 SSH 日志:

192.168.80.125 authlog: Received request to connect to host 192.168.80.100 port 80, but the request was denied.
192.168.80.125 authlog: Received request to connect to host 192.168.80.125 port 443, …
Run Code Online (Sandbox Code Playgroud)

security ubuntu ssh configuration forwarding

2
推荐指数
1
解决办法
1829
查看次数

IPv6 PPP 链路无法将路由器广告转发到本地 LAN

Debian 服务器具有eth0, eth1. eth2ppp0设备:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether xx:yy:zz:yy:xx:yy brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether xx:yy:zz:yy:xx:yy brd ff:ff:ff:ff:ff:ff
4: eth2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether xx:yy:zz:yy:xx:yy brd ff:ff:ff:ff:ff:ff
63: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1492 qdisc pfifo_fast state UNKNOWN qlen 3
    link/ppp
Run Code Online (Sandbox Code Playgroud)

到处都启用转发:

/proc/sys/net/ipv6/conf ~
  all/forwarding=1  default/forwarding=1
 eth0/forwarding=1     eth1/forwarding=1
 eth2/forwarding=1     ppp0/forwarding=1
Run Code Online (Sandbox Code Playgroud)

并且 autoconf 也被激活:

/proc/sys/net/ipv6/conf …
Run Code Online (Sandbox Code Playgroud)

ipv6 forwarding point-to-point-protocol icmpv6

1
推荐指数
1
解决办法
2028
查看次数