先添加一个虚拟网卡,修改/etc/network/interfaces

auto vmbr1
iface vmbr1 inet static
address 192.168.1.1
netmask 255.255.255.0
bridge_ports none
bridge_stp off
bridge_fd 0
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '192.168.1.0/24' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '192.168.1.0/24' -o vmbr0 -j MASQUERADE

开小鸡,只添加vmbr1网卡即可,IP配置为192.168.1.100/24(自己定),网关192.168.1.1,关闭防火墙(没关可能会有问题)

安装rinetd(略过)

修改/etc/rinetd.conf

0.0.0.0 10022 192.168.1.100 22  #将192.168.1.100的22端口映射到母鸡的10022,0.0.0.0表示母鸡绑定的所有IP,这里可以直接填公网IP

访问的IP 访问的端口 将请求转发到的IP 端口

为什么不用iptables?
rinetd配置非常简单,不用输一长串的命令,而且放在配置文件里也方便管理

分类: 教程 标签: rinetdPVE端口转发

评论

全部评论 1

  1. 20bet
    20bet
    Google Chrome Windows 10
    Your article gave me a lot of inspiration, I hope you can explain your point of view in more detail, because I have some doubts, thank you.

目录