Disabling DNS change in openvpn client
Gnome's network manager with OpenVPN lets you only get Addresses from the VPN server and have your own DNS server and search domains be configured. Not sure if your requirement is for a Desktop System or a server and what desktop environment you are using.
But, there exists a case where you might not be able to access your own DNS service (from the one provided by your service provider) because all your traffic including DNS'es would be routed from the VPN server. In this case you can manually set google's free DNS server addresses there.
Not sure if you are using network-manager's OpenVPN module to configure VPNs. But that would be a better way.
Also this script/tutorial might be of help to you.
Related videos on Youtube
atkawa7
Updated on September 18, 2022Comments
-
atkawa7 over 1 year
I am having trouble using fcntl() and fileno. I am having trouble implementing a lock mechanism. However when I try to close a file I get the following error fcntl: Bad file descriptor. I am using fileno to get the file description and I am getting -1.
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> //args ==path to the file int main(int argc, char *argv[]) { struct flock lock = {F_WRLCK, SEEK_SET, 0, 0, 0 }; int fd; FILE* fp; lock.l_pid = getpid(); if (argc > 1) lock.l_type = F_RDLCK; printf("%s\n", argv[1]); fp = fopen(argv[1], "w"); if(fp==NULL) { perror("fopen"); exit(1); } fd=fileno(fp); getchar(); if (fcntl(fd, F_SETLKW, &lock) == -1) { perror("fcntl"); exit(1); } lock.l_type = F_UNLCK; if (fcntl(fd, F_SETLK, &lock) == -1) { perror("fcntl"); exit(1); } close(fd); return 0; }
-
asio_guy over 8 yearsyou should have handled argc <= 1
-
-
julian joseph over 12 yearsI don't have access to the server.
-
Boban P. over 12 yearsAfter connecting your linux box to the vpn, try to manualy set dns servers that belong to a vpn routed network, and see if it's working.
-
julian joseph over 12 yearsThanks! What I did was dissect the openvpn configuration file (save keys into their own files etc.) and configure the gnome network manager by hand (instead of executing openvpn on the command line). Now it works as intended.
-
atkawa7 over 8 yearsThe problem is because of if (argc > 1) lock.l_type = F_RDLCK; which does not work with "w". I am putting a read lock but trying to write which do not work together well