vpnc-script: hack to support NetworkManager

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there!

In our setup, we can't use OpenConnect NetworkManager plugin (yet - need
to add some functionality there). Therefore, I use the following quick 
hack to make DNS work on OpenSUSE. 

It's for sure not for upstream inclusion, but perhaps it's still helpful 
for someone. Perhaps it would make sense to put it on the website or 
somewhere else?

--- a/vpnc-script
+++ b/vpnc-script
@@ -525,16 +525,32 @@ restore_resolvconf_generic() {
 
 modify_resolvconf_suse_netconfig()
 {
-       /sbin/netconfig modify -s vpnc -i "$TUNDEV" <<-EOF
-               INTERFACE='$TUNDEV'
-               DNSSERVERS='$INTERNAL_IP4_DNS'
-               DNSDOMAIN='$CISCO_DEF_DOMAIN'
-               EOF
+       # ugly hack to support NetworkManager setups in case you can't use NetworkManager plugin for OpenConnect
+       if nmcli c show --active | grep -q "$TUNDEV"; then
+               for s in $INTERNAL_IP4_DNS; do
+                       echo "Telling nmcli to use DNS $s"
+                       nmcli connection modify --temporary "$TUNDEV" +ipv4.dns $s
+               done
+               # needed to activate config, i.e. rewrite resolv.conf
+               nmcli connection up "$TUNDEV"
+       else
+               /sbin/netconfig modify -s vpnc -i "$TUNDEV" <<-EOF
+                       INTERFACE='$TUNDEV'
+                       DNSSERVERS='$INTERNAL_IP4_DNS'
+                       DNSDOMAIN='$CISCO_DEF_DOMAIN'
+                       EOF
+       fi
 }
 # Restore resolv.conf to old contents on Suse
 restore_resolvconf_suse_netconfig()
 {
-       /sbin/netconfig remove -s vpnc -i "$TUNDEV"
+       # ugly hack to support NetworkManager setups in case you can't use NetworkManager plugin for OpenConnect
+       if nmcli c show --active | grep -q "$TUNDEV"; then
+               echo "Telling nmcli to forget $TUNDEV configuration"
+               nmcli c delete $TUNDEV
+       else
+               /sbin/netconfig remove -s vpnc -i "$TUNDEV"
+       fi
 }
 
 # === resolv.conf handling via /sbin/modify_resolvconf (Suse) =====================

-- 
With kind regards,

Gernot Hillier
Siemens AG, Corporate Competence Center Embedded Linux



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux