diff --git a/xCAT-server/lib/xcat/plugins/route.pm b/xCAT-server/lib/xcat/plugins/route.pm index b523c6c9a..27967f8d6 100644 --- a/xCAT-server/lib/xcat/plugins/route.pm +++ b/xCAT-server/lib/xcat/plugins/route.pm @@ -614,7 +614,11 @@ sub set_route { } } else { if (xCAT::Utils->isLinux()) { - $cmd="route add -net $net netmask $mask gw $gw_ip dev $ifname"; + if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) { + $cmd="route add -net $net netmask $mask dev $ifname"; + } else { + $cmd="route add -net $net netmask $mask gw $gw_ip"; + } } else { $cmd="route add -net $net -netmask $mask $gw_ip"; } @@ -1125,7 +1129,11 @@ sub addPersistentRoute_Debian{ } else { #ipv4 $cmd = "grep \"-net $net netmask $mask gw $gw_ip\" $conf_file"; - $route_conf = " up route add -net $net netmask $mask gw $gw_ip dev $ifname \n down route del -net $net netmask $mask gw $gw_ip dev $ifname\n"; + if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) { + $route_conf = " up route add -net $net netmask $mask dev $ifname \n down route del -net $net netmask $mask dev $ifname\n"; + } else { + $route_conf = " up route add -net $net netmask $mask gw $gw_ip \n down route del -net $net netmask $mask gw $gw_ip\n"; + } } #fine the corresponding config in the config file