route add command
Hi!
I have a machine with many network interfaces. I would like to add a command to say that for a destitanations tha packets shoudl be sent on port hme0 and that the source IP should be x.x.x.x
I now the following command but how can I specific the interface hme0?
route add 172.24.169.136 10.211.4.1 -setsrc 10.211.4.211
[347 byte] By [
pityq] at [2007-11-26 10:41:16]

# 1
The solaris routing table does not control source addresses. You cannot do what you want directly.
ipfilter includes a nat module that can rewrite packets if necessary.
Solaris 10 has an option to ifconfig that specifies the default source address for connections that do not override it (like an existing TCP connection would).
--
Darren
# 2
Hello,
Darren: what you said is only partially true, the option "-setsrc" has been designed to change the source IP adress in the outgoing packets but you're right in the sense that it has been designed for a carrier-grade protocol which is not delivered in standard.
To be honest, I've never test it in a standard context ... but it is documented and it works so just try and if it works for you, that's fine.
About "how to configure the interface", the interface used for the outgoing message is the one associated to the IP adress defined in the "gateway" argument but in that case; it is better to define a network routing than a host routing.
Laurent.
# 3
Hi!
Thanks for the help. I managed to add the route record. My problem is that it's not in the wright place.
My netstat -rn is:
DestinationGatewayFlags RefUseInterface
-- ------
192.168.1.0 192.168.1.41U 10qfe0
192.168.1.0 192.168.1.43U 10qfe1
10.211.4.010.211.4.28 U 1117hme0
172.24.169.010.211.4.214U 16hme0:1
224.0.0.0 10.211.4.28 U 10hme0
default10.211.4.1UG1255
127.0.0.1 127.0.0.1UH577lo0
After adding the following route:
route add 10.211.4.0/24 10.211.4.214 -interface
And the resulting netstat is:
DestinationGatewayFlags RefUseInterface
-- -- -- --
192.168.1.0 192.168.1.41U 10qfe0
192.168.1.0 192.168.1.43U 10qfe1
10.211.4.010.211.4.28 U 1119 hme0
10.211.4.010.211.4.214U 10hme0:1
172.24.169.010.211.4.214U 16hme0:1
224.0.0.0 10.211.4.28 U 10hme0
default10.211.4.1UG1259
127.0.0.1127.0.0.1 UH577lo0
So this means that the new rout record for 10.211.4.0 was put in the routing table below the old registration. If I know well the routing table is used from top to down it means that new registartion has no effect. Is there any way to put this as the first registration or at least above the old one?
Thanks.
pityq at 2007-7-7 2:52:52 >

# 8
If you create a zone and give the new IP to the zone then any applications running in that zone
will definetely use a SRC IP of the zone.
Alternately, if you have the source code of the application you can change it to specifically bind to the IP you want. Some applications already have the functionality available.
# 10
You might be able to make use of ipfilter to do this, but I don't have an example of how to do the rewrites.
Here's a post where I quoted Casper Dik's description of how to do something similar. It might be relevant for you.
http://groups.google.com/group/comp.unix.solaris/browse_frm/thread/cd09859a39c4 773c
--
Darren