> machine1 IP:172.30.11.119
> machine2 IP:172.30.11.120
> machine3 IP:172.30.11.121
> machine4 IP:172.30.11.122
Note:
These machines are connected to LAN.
我已经在/ etc / network / interfaces文件中为每台机器的以太网接口配置了静态IP,以便在系统重启后保持IP.
我在机器4中将默认网关设置为172.30.11.97(以便通过putty连接管理器从用户桌面访问它)
allow-hotplug eth0
iface eth0 inet static
address 172.30.11.122
netmask 255.255.255.0
gateway 172.30.11.97
但是在其他3台机器中,我没有像122那样设置默认网关.相反,我在“接口”和“rt_table”文件中尝试了下面这3台机器中的策略路由:
echo "1 policy_gw" >> /etc/iproute/rt_table
In /etc/iproute/rt_table:
1 policy_gw
在/ etc / network / interfaces中:
allow-hotplug eth0
iface eth0 inet static
address 172.30.11.121
netmask 255.255.255.0
post-up ip rule add dev eth0 table policy_gw
post-up ip route add default via 172.30.11.97 dev etho src 172.30.11.121/24 table policy_gw
就像120/119机器一样.现在我可以直接通过putty到达这些机器.
面临的问题:我能够从同一局域网中的其他机器ping这个局域网中的每台机器.但是ssh因错误端口22而失败:没有到主机的路由
假设我在机器121中:ssh 172.30.11.120抛出上述错误.
default gateway is a cisco system router/switch.They are blocking
ports for SSH,telnet protocols but not ICMP.
机器122的路由表:
root@debian:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.30.11.97 0.0.0.0 UG 0 0 0 eth1
172.30.11.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
ssh_config文件的内容:
Host *
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no