我在Solaris上有两个接口
# ifconfig -a lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2 inet 192.168.1.41 netmask ffffff00 broadcast 192.168.1.255 ether x:x:x:x:x:x hme1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3 inet 192.168.1.42 netmask ffffff00 broadcast 192.168.1.255 ether x:x:x:x:x:x # netstat -rn Routing Table: IPv4 Destination Gateway Flags Ref Use Interface -------------------- -------------------- ----- ----- ------ --------- 192.168.1.0 192.168.1.41 U 1 91 hme0 192.168.1.0 192.168.1.42 U 1 0 hme1 224.0.0.0 192.168.1.41 U 1 0 hme0 default 192.168.1.1 UG 1 91 127.0.0.1 127.0.0.1 UH 1 0 lo0
hme0的默认接口,但我想指定主机192.168.1.32使用接口hme1。 我尝试使用
route add 192.168.1.32 192.168.1.42 -interface hme1
但是回报
hme1: bad value
任何想法我怎么能解决它?
似乎所有的答复只适用于Linux平台。
但是,在Solaris 10上,我发现它的工作原理是:
route -p <add/delete> <hostname> <gateway> -ifp <interface>
l1x的解决scheme是正确的 ,但有一些问题; hme0端的其他主机不能达到192.168.1.32可能无法到达其他主机。
如果这是一个问题,这是因为你的networking掩码说192.168.1.*连接到两个networking,这是不正确的。 也许你想在没有子网的情况下做到这一点,并将掩码设置为255.255.255.255 ,这将允许您创build不含 -interface行的路由。
也许你可以在一边使用192.168.2.* ,然后路由另一边,尽pipe你需要在路由器上创build路由,或者重新configuration192.168.1.*networking上的所有机器来了解这个路线。
如果你不能做这些事情,你可能会创造一个桥梁。
如果你不害怕修补你的内核并加载alpha质量的驱动程序,你可以制作一个以太网桥 (也可以参考RBridge )。
如果一个IP专用的解决scheme是足够的,你可以使用代理arp和IP转发来build立一个粗糙的IP专用桥接器。 从这样的事情开始:
arp -s 192.168.1.32 macaddress-of-hme0 pub route add 192.168.1.32 secretip ndd -set /dev/ip ip_forawrding 1
在Solaris下,proxy_arp确实被破坏了。 唯一可行的方法是给机器192.168.1.32一个额外的秘密IP地址 ,例如10.5.3.2,你只用于这个。
,-----, hme1,-----, hme0 |hostA|-------------|hostB |----------- ? `-----' `-----' 192.168.1.32 192.168.1.41 10.5.3.2 192.168.1.42 10.5.3.1
尽pipe在此configuration中,“hostB”不需要192.168.1.41 和 192.168.1.42 。
这将在Solaris 10上的命令:
route add 192.168.1.32 192.168.1.42 -interface
您不需要在参数interface之后添加接口名称,因为IP地址192.168.1.42已经隐含地指出使用hme1。
问候,
solaris路由语法是follewing:
route [-fn] add | delete | get [net|host|default] [destination] [gateway]
所以你的命令是这样的:
route add 192.168.1.32 -interface hme1
试试这个:route add -net 192.168.1.0 -netmask 255.255.255.0 -interface 192.168.1.42