
我想通过交叉连接两台机器,并希望他们共享一个networking,所以我只有一个DHCP服务器与一个networking,每个服务器在这个局域网可以连接到对方。 这是有道理的,或者是两个独立的DHCP服务器和networking更好的方式?
下面我添加了一些configuration,我做了一些连接testing。
总之 :
如果我SSH连接到machine1端口5678到10.62.62.20的连接工作,我只能从machine1上的连接看到shorewall日志条目。 但如果我连接到machine2端口5678连接不起作用,我可以看到machine1上的火星日志
Nov 29 15:26:57 machine1 kernel: [ 7495.749894] martian source **ssh.client.ip.addr** from **yyy.yyy.yyy.yyy**, on dev br1
machine1 / etc / shorewall /规则
***snip*** DNAT:debug net lan:10.62.63.20:22 tcp 5678 - xxx.xxx.xxx.xxx ***snip***
machine2 / etc / shorewall /规则
***snip*** DNAT:debug net lan:10.62.63.30:22 tcp 5678 - yyy.yyy.yyy.yyy ***snip***
machine1 / etc / networking / interfaces
# Loopback device: auto lo iface lo inet loopback # device: eth0 #allow-hotplug eth0 auto eth0 iface eth0 inet manual # device: eth1 #allow-hotplug eth1 auto eth1 iface eth1 inet manual auto br0 iface br0 inet static address xxx.xxx.xxx.xxx broadcast xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx gateway xxx.xxx.xxx.xxx bridge_ports eth0 bridge_fd 0 bridge_hello 2 bridge_maxage 12 bridge_maxwait 0 bridge_stp off auto br1 iface br1 inet static address 10.62.63.1 broadcast 10.62.63.255 netmask 255.255.255.0 bridge_ports eth1 bridge_fd 0 bridge_hello 2 bridge_maxage 12 bridge_maxwait 0 bridge_stp off
machine2 / etc / networking / interfaces
# Loopback device: auto lo iface lo inet loopback # device: eth0 #allow-hotplug eth0 auto eth0 iface eth0 inet manual # device: eth1 #allow-hotplug eth1 auto eth1 iface eth1 inet manual auto br0 iface br0 inet static address yyy.yyy.yyy.yyy broadcast yyy.yyy.yyy.yyy netmask yyy.yyy.yyy.yyy gateway yyy.yyy.yyy.yyy bridge_ports eth0 bridge_fd 0 bridge_hello 2 bridge_maxage 12 bridge_maxwait 0 bridge_stp off auto br1 iface br1 inet static address 10.62.63.3 broadcast 10.62.63.255 netmask 255.255.255.0 bridge_ports eth1 bridge_fd 0 bridge_hello 2 bridge_maxage 12 bridge_maxwait 0 bridge_stp off
ip route show yyy.yyy.yyy.yyy/yy dev br0 proto kernel scope link src yyy.yyy.yyy.yyy 10.62.63.0/24 dev br1 proto kernel scope link src 10.62.63.1 default via yyy.yyy.yyy.yyy dev br0
ping 10.62.63.3到br1 ip(remote):ok ping 10.62.63.1到br1 ip(local):ok ping 10.62.63.2到dns(本地):ok ping 10.62.63.20到web01(本地):好的 ping 10.62.63.30到web02(远程):好的 ssh 10.62.63.20到web01(本地):好的 ssh 10.62.63.30到web02(远程):好的 ip route show yyy.yyy.yyy.yyy/yy dev br0 proto kernel scope link src yyy.yyy.yyy.yyy 10.62.63.0/24 dev br1 proto kernel scope link src 10.62.63.3 default via yyy.yyy.yyy.yyy dev br0
ping 10.62.63.3到br1 ip(local):ok ping 10.62.63.1到br1 ip(remote):ok ping 10.62.63.2到dns(远程):好的 ping 10.62.63.20到web01(远程):ok ping 10.62.63.30到web02(本地):好的 ssh 10.62.63.20到web01(远程):ok ssh 10.62.63.30到web02(本地):好的 问题是出站数据包,而不是入站。
dhcp服务器为两台机器提供了相同的网关(10.62.63.1),所以dnat机器上的入站数据包到达他们的位置(machine2上的web)没有问题,但是返回的数据包被发送到machine1的网关(10.62。 63.1)而不是来自何处(10.62.63.3)。
所以它作为martion包在machine1上。
解决方法是在dns(dnsmasq)上添加标签,以便不同主机上的虚拟机获得不同的网关:
/etc/dnsmasq.conf
*** snip *** dhcp-host=set:machine1,ff:ff:ff:ff:ff:ff,web01,10.62.63.20 dhcp-host=set:machine2,ee:ee:ee:ee:ee:ee,web02,10.62.63.30 dhcp-option=tag:machine1,option:router,10.62.63.1 dhcp-option=tag:machine2,option:router,10.62.63.3 *** snip ***