From 313178cee62bcb79e9ba8e0cdc131985b7a6d93d Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Mon, 22 Mar 2021 15:23:31 +0100 Subject: [PATCH] use route to get network interface with default gateway to find correct IP addess --- startup.script_linux | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/startup.script_linux b/startup.script_linux index d6bc1bc..9a219f0 100644 --- a/startup.script_linux +++ b/startup.script_linux @@ -43,7 +43,7 @@ epicsEnvSet CA_AUTO_172.25,"NO" # All others can work with the defaults: automatic # Apply settings dependent on network -system "/sbin/ifconfig|awk -F '[.: ]+' -vP=epicsEnvSet -vN=NET -vI=IPADDR -vB=BCADDR -vD=. '/docker|virbr|lo:/{do{getline}while($0);next}/192\.168/{next}/Bcast/{print P,N 1,$9ORS P,N 2,$10ORS P,N 3,$11ORS P,I,$4D$5D$6D$7ORS P,B,$9D$10D$11D$12;exit}/broadcast/{print P,N 1,$13ORS P,N 2,$14ORS P,N 3,$15ORS P,I,$3D$4D$5D$6ORS P,B,$13D$14D$15D$16;exit}'>/tmp/$(IOC).net" +system "/sbin/ifconfig `/sbin/route -n|awk '/^0.0.0.0/{print $8}'`|awk -F '[.: ]+' -vP=epicsEnvSet -vN=NET -vI=IPADDR -vB=BCADDR -vD=. '/Bcast/{print P,N 1,$9ORS P,N 2,$10ORS P,N 3,$11ORS P,I,$4D$5D$6D$7ORS P,B,$9D$10D$11D$12}/broadcast/{print P,N 1,$13ORS P,N 2,$14ORS P,N 3,$15ORS P,I,$3D$4D$5D$6ORS P,B,$13D$14D$15D$16}'>/tmp/$(IOC).net" < /tmp/$(IOC).net system "rm /tmp/$(IOC).net" epicsEnvSet EPICS_CA_ADDR_LIST,"$(CA_$(NET1=).$(NET2=).$(NET3=)=$(CA_$(NET1=).$(NET2=)=))"