I have a laptop with 2 interfaces eth0 - wired eth1 - wireless
I want to use eth0 when i am at my desk and eth1 when i am away. But to keep all my long live connections like telnet and ssh going even when i pull the cable from eth0, i want them to always use eth1, even when eth0 is up and functioning.
i am using the 2.4.20-19.9 kernel shipped by redhat and am trying to use iproute2 and iptables to try to achieve this but am unable to...could somebody please look at what i am doing (below) and tell me what i am missing.
by default I have the following routing table
[root@myhost]# /sbin/route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.27.18.0 * 255.255.255.0 U 0 0 0 eth0
10.27.16.0 * 255.255.254.0 U 0 0 0 eth1
169.254.0.0 * 255.255.0.0 U 0 0 0 eth1
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default 10.27.18.1 0.0.0.0 UG 0 0 0 eth0
default 10.27.16.1 0.0.0.0 UG 0 0 0 eth1
that seems to take care that all traffic picks the route through eth0 (wired).
I added another routing table (7) and added all the routing entries through interface eth1 (wireless) to it
[root@myhost]# /sbin/ip route show table 7 10.27.16.0/23 dev eth1 proto kernel scope link src 10.27.17.208 169.254.0.0/16 dev eth1 scope link 127.0.0.0/8 dev lo scope link default via 10.27.16.1 dev eth1
At this point i have no iptables rules, and added 2 new ones to mangle any traffic going to ports 22/23 to set a mark of 7
[root@myhost]# /sbin/iptables -t mangle -A PREROUTING -p tcp --dport 22 -j MARK --set-mark 7
[root@myhost]# /sbin/iptables -t mangle -A PREROUTING -p tcp --dport 23 -j MARK --set-mark 7
and after that, i see
[root@myhost]# /sbin/iptables --list -t mangle
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
MARK tcp -- anywhere anywhere tcp dpt:ssh MARK set 0x7
MARK tcp -- anywhere anywhere tcp dpt:telnet MARK set 0x7
Chain INPUT (policy ACCEPT) target prot opt source destination
Chain FORWARD (policy ACCEPT) target prot opt source destination
Chain OUTPUT (policy ACCEPT) target prot opt source destination
Chain POSTROUTING (policy ACCEPT) target prot opt source destination
--- i then add a new routing rule
[root@myhost]# /sbin/ip rule add fwmark 7 table 7 [root@myhost]# /sbin/ip rule show 0: from all lookup local 32765: from all fwmark 0x7 lookup 7 32766: from all lookup main 32767: from all lookup 253
and flush the cache [root@myhost]# /sbin/ip route flush cache
and because i am not sure, i turn on ip_forwarding [root@myhost]# echo 1 > /proc/sys/net/ipv4/ip_forward
At this point i expected all my new telnet and ssh sessions to use eth1...but they still use the default route through eth0 (the netstat command on the host shows its establised a connection to the 10.27.18.105 address, which is the address on eth0) which makes me lose my sessions when i unplug the cable.
what am i missing here, please help. thanks sivaram
_________________________________________________________________
Frustrated with dial-up? Get high-speed for as low as $29.95/month (depending on the local service providers in your area). https://broadband.msn.com
- : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html