Need help for route command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manjuks
    New Member
    • Dec 2007
    • 72

    Need help for route command

    Hi All,

    I need help to port below command to LINUX, it was written for Solaris platform

    Code:
    $cmd = "/usr/sbin/route [B]-n[/B] add [B]-host[/B] $hoc [B]-gateway[/B] $gatewayIp [B]-setsrc[/B] $vcip";
    In Linux route command exists, and these add gateway options are available. But last option -setsrc is not available in LINUX. It represents “Assigns the default source address”, I didn't understand clearly... Can any one please explain me what it represents? I had gone through man page and searched in net, But could not get anything.

    It would be great help if you can guide me how I can port this to Linux OS.

    Thanks in advance

    --Manju
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    If you have multiple interfaces for same network.
    Say, eth0 172.18.28.90 and eth1 172.18.28.91. In this case, solaris will choose first working device as a output interface. If you have to change the interface for all output traffic then you basically specifies with -setsrc switch.

    In case of linux, just specify eth0 or eth1 whichever you may need. If you have only single interface don't bother about those options.

    something like this:

    route add default gw 172.18.28.1 eth0

    Comment

    • manjuks
      New Member
      • Dec 2007
      • 72

      #3
      Hi ashitpro

      Thanks for your reply..

      Shall I replace this
      Code:
      $cmd = "/usr/sbin/route -n add -host $hoc -gateway $gatewayIp -setsrc $vcip";
      With this...

      Code:
      $cmd = "/sbin/route -n add -host $hoc -gw $gatewayIp" ;
      
      $dev = `netstat -ie | grep -B1 135.254.239.52  | head -n 1 | awk '{print $1}'`;
      
      $cmd = "/sbin/route add default gw $vcip $dev;
      Thanks,
      Manju

      Comment

      Working...