我在我的脸eth0上有两个ip地址:
eth0 Link encap:Ethernet HWaddr 00:19:99:a4:14:08
inet addr:85.25.152.115 Bcast:85.25.152.255 Mask:255.255.255.0
inet6 addr: fe80::219:99ff:fea4:1408/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:233866 errors:0 dropped:0 overruns:0 frame:0
TX packets:145186 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:175800889 (167.6 MiB) TX bytes:38033903 (36.2 MiB)
Interrupt:18
eth0:1 Link encap:Ethernet HWaddr 00:19:99:a4:14:08
inet addr:85.25.248.216 Bcast:85.25.248.255 Mask:255.255.255.192
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:18 我为virtualbox客户提供了一个内部虚拟界面:
tap0 Link encap:Ethernet HWaddr ae:ba:ce:d7:7d:bd
inet addr:10.0.1.1 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::acba:ceff:fed7:7dbd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:111 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)10.0.1.1是VM的GW (10.0.1.2)。从10.0.1.2到internet的转发非常有效,但是当我试图将所有端口从85.25.248.216 (eth0:1)重定向到10.0.1.2时,它失败了:
iptables -t nat -A PREROUTING -d 85.25.248.216 -j DNAT --to-destination 10.0.1.2
nmap -A -v 85.25.248.216
<...>
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 5.8p1 Debian 4 (protocol 2.0)
| ssh-hostkey: 1024 4e:3e:ce:86:24:f8:54:7a:68:67:be:57:92:62:00:f0 (DSA)
|_2048 36:f5:0d:4c:1b:58:b8:f9:ff:0f:47:ba:88:43:69:bd (RSA)
10000/tcp open http MiniServ 1.540 (Webmin httpd)
|_html-title: Site doesn't have a title (text/html).
Device type: general purpose
Running: Linux 2.6.X
OS details: Linux 2.6.19 - 2.6.31
india827:~# iptables --list -t nat
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT all -- anywhere static-ip-85-25-248-216.inaddr.intergenia.de to:10.0.1.2
DNAT tcp -- anywhere static-ip-85-25-248-216.inaddr.intergenia.de tcp dpt:3389 to:10.0.1.2
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
DNAT all -- anywhere static-ip-85-25-248-216.inaddr.intergenia.de to:10.0.1.2
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- anywhere anywhere
SNAT all -- anywhere anywhere to:85.25.248.216 VM在Windows上,至少必须打开3389 (RDP),但是我(当然!)也无法连接到它。哪里出错了?
iptables -t nat -A PREROUTING -d 85.25.248.216 -j DNAT --to-destination 10.0.1.2
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate NEW -d 10.0.1.2 -j ACCEPT结果是一样的。
发布于 2011-04-06 19:45:51
iptables命令是正确的,所以它必须是上下文中的内容。我试试看。
未启用
cat /proc/sys/net/ipv4/ip_forward应该给出1的值。如果没有,则将其设置为
echo 1 > /proc/sys/net/ipv4/ip_forwardiptables --list -t nat应该能透露出来。
发布于 2011-06-03 22:55:52
为什么不直接使用Virtualbox NAT转发?
http://www.virtualbox.org/manual/ch06.html#natforward
然后调整iptables来打开主机端口。您已经在Virtualbox中运行NAT路由器,为什么要运行两个?
https://serverfault.com/questions/256508
复制相似问题