[Openswan dev] Re: Openswan 2.4.0dr9 multiple defaultroute patch

Dirk Nehring dnehring at marcant.net
Mon Aug 15 22:57:39 CEST 2005


On Mon, Aug 15, 2005 at 09:30:34PM +0200, Paul Wouters wrote:
> On Mon, 15 Aug 2005, mcr at xelerance.com wrote:
>
> > How about, instead:
> >
> >defaultinterface() {
> >	phys=`netstat -nr |
> >		awk '$1 == "0.0.0.0" && $3 == "0.0.0.0" { print $NF; exit }'`
>
> Can we use the 'ip' command instead? Officially, netstat is obsoleted on
> Linux.

Oh yes:

defaultinterface() {
	phys=`ip route list |
		 awk '$1 == "default" { print $5; exit }'`


and some lines down...

       next=`ip route list |
               awk '$1 == "default" { print $3; exit }'`


line 104, _startklips.in:
        # figure out ifconfig for interface
        addr=
-       eval `ifconfig $phys |
-               awk '$1 == "inet" && $2 ~ /^addr:/ && $NF ~ /^Mask:/ {
-                       gsub(/:/, " ", $0)
-                       print "addr=" $3
-                       other = $5
-                       if ($4 == "Bcast")
+       eval `ip addr show dev $phys label $phys  |
+               awk '$1 == "inet" {
+                       print "addr=" $2
+                       other = $4
+                       if ($3 == "brd")
                                print "type=broadcast"
-                       else if ($4 == "P-t-P")
-                               print "type=pointopoint"
+                       else if ($3 == "peer")
+                               print "type=peer"
                        else if (NF == 5) {
                                print "type="
                                other = ""

in line ~145:

-               ifconfig $virt inet $addr $type $otheraddr netmask $mask $mtu
+               ip addr add $addr $type $otheraddr dev $virt
+               ip link set $virt $mtu up



Dirk


More information about the Dev mailing list