I know I can route to another computer by setting its IP as the gateway. Can I also do this by just specifying the interface the packets should take. Like instead of doing route add gw, if I say route add -net X dev interface, it doesn't work.
Can I route through interface instead of IP?
route
No. The reason is that there can be any number of hosts connected to that interface, how is your machine supposed to know which one the traffic should be routed through?If you only want to send a small subset of traffic through the designated host, and not all traffic, yes, you can do that.ip route add 1.2.3.0/24 via 192.168.0.123 dev eth1This will send all traffic destinted to 1.2.3.0/24 through 192.168.0.123 which is connected to eth1.