搞这一块搞很久了 教程看了很多
Prerouting也做了
Forward也做了
但就是一直无法内网穿透到KVM虚拟机里面的远程桌面服务
本人使用的是ubuntu,ufw本身好像对于端口映射支援不太好 所以要求使用iptables
如果你有别的方案可以使用也可以提出来
最好是能使用VNC线上操作
请别丢教程网站给我。 我看了很多 但就是没头绪 也有操作过
sysctl.conf
有把forward转发打开
Prerouting
Postrouting
Forward
都试过了
要求
1.Input policy为Drop (把非本机请求 或是不在我的Accept清单的接入连线都丢弃,防止简易DDOS)
2.可以内网穿透,端口映射
3.基本上就这样,希望你不介意我在不懂的环节上面问你
4.使用VNC 我要看到你做了啥我才知道到底该怎么做,教程看了很多也搞不明,重装了好几次linux
最佳解答100全得。
不是很清楚你那边网络结构是什么样,内网穿透应该要网关能够支持才行吧(?)
听你的需求,或许一个 frp 就能做到?
付费购买大厂的集群吧,你这个自己开发,安全没有保证,而且效率也不高,像阿里云和腾讯云,这方面的技术是非常的成熟,部署难度几乎为零,如果真的想要快速投入生产的话,推荐使用现成的
http://www.hdrorz.name/archives/154
我安装了kvm,并使用vmbuilder在服务器上设置了多个guest虚拟机。这是以下配置:
server host1 (xxx.xxx.xxx.xxx) -> guest vm1 (192.168.122.203)
-> guest vm2 (192.168.122.204)
其中xxx.xxx.xxx.xxx是host1的固定IP地址。
我想使用以下命令连接到vm1:
ssh username@host1 -p 2222
我试图通过在iptables中添加以下规则来做到这一点:
sudo iptables --table nat --append PREROUTING --protocol tcp --destination xxx.xxx.xxx.xxx --destination-port 2222 --jump DNAT --to-destination 192.168.122.203:22
但是我运行时出现超时:
ssh username@host1 -p 2222
这是我的iptables规则:
sudo iptables -nL -v --line-numbers -t nat
Chain PREROUTING (policy ACCEPT 32446 packets, 3695K bytes)
num pkts bytes target prot opt in out source destination
1 7 420 DNAT tcp -- * * 0.0.0.0/0 xxx.xxx.xxx.xxx tcp dpt:2222 to:192.168.122.203:22
Chain INPUT (policy ACCEPT 8961 packets, 968K bytes)
num pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 350 packets, 23485 bytes)
num pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 357 packets, 23905 bytes)
num pkts bytes target prot opt in out source destination
1 151 9060 MASQUERADE tcp -- * * 192.168.122.0/24 !192.168.122.0/24 masq ports: 1024-65535
2 99 7524 MASQUERADE udp -- * * 192.168.122.0/24 !192.168.122.0/24 masq ports: 1024-65535
3 3 252 MASQUERADE all -- * * 192.168.122.0/24 !192.168.122.0/24
sudo iptables -nL -v --line-numbers
Chain INPUT (policy ACCEPT 14 packets, 1147 bytes)
num pkts bytes target prot opt in out source destination
1 454 30229 ACCEPT udp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:53
2 0 0 ACCEPT tcp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
3 0 0 ACCEPT udp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:67
4 0 0 ACCEPT tcp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 589K 2304M ACCEPT all -- * virbr0 0.0.0.0/0 192.168.122.0/24 state RELATED,ESTABLISHED
2 403K 24M ACCEPT all -- virbr0 * 192.168.122.0/24 0.0.0.0/0
3 0 0 ACCEPT all -- virbr0 virbr0 0.0.0.0/0 0.0.0.0/0
4 1 60 REJECT all -- * virbr0 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
5 0 0 REJECT all -- virbr0 * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
Chain OUTPUT (policy ACCEPT 4 packets, 480 bytes)
我在nat表中添加了这2条规则:
$sudo iptables -t nat -A PREROUTING -p tcp --dport 2222 -j DNAT --to-destination 192.168.122.203:22
$sudo iptables -t nat -A POSTROUTING -p tcp --dport 22 -d 192.168.122.203 -j SNAT --to 192.168.122.1
然后我删除了表格过滤器FORWARD链的规则4和5
$sudo iptables -nL -v --line-numbers -t filter
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
(...)
4 7 420 REJECT all -- * virbr0 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
5 0 0 REJECT all -- virbr0 * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
$sudo iptables -D FORWARD 5 -t filter
$sudo iptables -D FORWARD 4 -t filter
现在,我通过执行以下操作连接到vm1:
$ssh user1@host -p 2222
user1@vm1:~$
物理机 有一个对外的公网IP 然后一个 KVM的内部IP
肯定没有啥不支持的问题 firewall设置问题而已
同样配置 windows的我就会设定 Linux真的抓瞎
你档次那个库来这里快递费
不了解具体结构,而且搞这个,设备不支持好像不行的。
我进来围观学习。。。