updatedate routes scripts so that we can route through a device
This commit is contained in:
parent
a487eeda81
commit
abbd20549a
@ -614,7 +614,7 @@ sub set_route {
|
||||
}
|
||||
} else {
|
||||
if (xCAT::Utils->isLinux()) {
|
||||
$cmd="route add -net $net netmask $mask gw $gw_ip";
|
||||
$cmd="route add -net $net netmask $mask gw $gw_ip dev $ifname";
|
||||
} else {
|
||||
$cmd="route add -net $net -netmask $mask $gw_ip";
|
||||
}
|
||||
@ -966,7 +966,7 @@ sub addPersistentRoute_RH {
|
||||
if ($net =~ /:/) {
|
||||
$filename="/etc/sysconfig/static-routes-ipv6";
|
||||
} else {
|
||||
$filename="/etc/sysconfig/static-routes";
|
||||
$filename="/etc/sysconfig/sysconfig/route-$ifname";
|
||||
}
|
||||
my @output=getConfig($filename);
|
||||
#print "old output=" . join("\n", @output) . "\n";
|
||||
@ -987,7 +987,7 @@ sub addPersistentRoute_RH {
|
||||
|
||||
$new_config="$ifname $net/$mask $gw_ip";
|
||||
} else {
|
||||
$new_config="any net $net netmask $mask gw $gw_ip $ifname\n";
|
||||
$new_config="$net/$mask via $gw_ip dev $ifname\n";
|
||||
}
|
||||
if (!$hasConfiged) {
|
||||
push(@output, $new_config);
|
||||
@ -1024,7 +1024,7 @@ sub deletePersistentRoute_RH {
|
||||
if ($net =~ /:/) {
|
||||
$filename="/etc/sysconfig/static-routes-ipv6";
|
||||
} else {
|
||||
$filename="/etc/sysconfig/static-routes";
|
||||
$filename="/etc/sysconfig/network-scripts/route-$ifname";
|
||||
}
|
||||
my @output=getConfig($filename);
|
||||
#print "old output=" . join("\n", @output) . "\n";
|
||||
@ -1046,7 +1046,7 @@ sub deletePersistentRoute_RH {
|
||||
if ($net =~ /:/) {
|
||||
$rsp->{data}->[0]= "$host: Removed persistent route \"$ifname $net/$mask $gw_ip\" from $filename.";
|
||||
} else {
|
||||
$rsp->{data}->[0]= "$host: Removed persistent route \"any net $net netmask $mask gw $gw_ip $ifname\" from $filename.";
|
||||
$rsp->{data}->[0]= "$host: Removed persistent route \"$net/$mask via $gw_ip dev $ifname\" from $filename.";
|
||||
}
|
||||
$callback->($rsp);
|
||||
} else {
|
||||
@ -1054,7 +1054,7 @@ sub deletePersistentRoute_RH {
|
||||
if ($net =~ /:/) {
|
||||
$rsp->{data}->[0]= "$host: Persistent route \"$ifname $net/$mask $gw_ip\" does not exist in $filename.";
|
||||
} else {
|
||||
$rsp->{data}->[0]= "$host: Persistent route \"any net $net netmask $mask gw $gw_ip $ifname\" does not exist in $filename.";
|
||||
$rsp->{data}->[0]= "$host: Persistent route \"$net/$mask via $gw_ip dev $ifname\" does not exist in $filename.";
|
||||
}
|
||||
$callback->($rsp);
|
||||
}
|
||||
@ -1125,7 +1125,7 @@ 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 \n down route del -net $net netmask $mask gw $gw_ip \n";
|
||||
$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";
|
||||
}
|
||||
|
||||
#fine the corresponding config in the config file
|
||||
|
@ -278,9 +278,9 @@ add_persistent_route()
|
||||
# $net/mask does not work with sed cmd
|
||||
route1="$ifname $net\/$mask $gw";
|
||||
else
|
||||
filename="/etc/sysconfig/static-routes";
|
||||
route="any net $net netmask $mask gw $gw $ifname";
|
||||
route1="any net $net netmask $mask gw $gw $ifname";
|
||||
filename="/etc/sysconfig/network-scripts/route-$ifname";
|
||||
route="$net/$mask via $gw dev $ifname";
|
||||
route1="$net\/$mask via $gw dev $ifname";
|
||||
fi
|
||||
if [ -f $filename ]; then
|
||||
grep "$route" $filename 2>&1 1>/dev/null
|
||||
@ -400,9 +400,9 @@ rm_persistent_route()
|
||||
route="$ifname $net\/$mask $gw"
|
||||
route1="$ifname $net/$mask $gw"
|
||||
else
|
||||
filename="/etc/sysconfig/static-routes";
|
||||
route="any net $net netmask $mask gw $gw $ifname";
|
||||
route1="any net $net netmask $mask gw $gw $ifname";
|
||||
filename="/etc/sysconfig/network-scripts/route-$ifname";
|
||||
route="$net/$mask via $gw dev $ifname";
|
||||
route1="$net\/$mask via $gw dev $ifname";
|
||||
fi
|
||||
if [ -f $filename ]; then
|
||||
grep "$route" $filename 2>&1 1>/dev/null
|
||||
@ -438,7 +438,11 @@ if [ "$op" = "add" ]; then
|
||||
fi
|
||||
else
|
||||
if [ "$(uname -s)" = "Linux" ]; then
|
||||
cmd="route add -net $net netmask $mask gw $gw"
|
||||
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
|
||||
cmd="route add -net $net netmask $mask dev $iface"
|
||||
else
|
||||
cmd="route add -net $net netmask $mask gw $gw"
|
||||
fi
|
||||
else
|
||||
cmd="route add -net $net -netmask $mask $gw"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user