I have a VPS with these public IP-addresses:
xx.xx.xx.192 (This IP-address is assigned to eth0)
eth0 is configured with static IP. Gateway is xx.xx.xx.254, netmask is 255.255.255.0
ipv4_forward is 1.
I have no iptables rules yet. This server is not standing behind a NAT-restricted network.
(I don't need to open ports for services anywhere, just set up the service and connect to the server via the port.)
I want to make that the OpenVPN server assigns all the public IPs to the clients, except .192, of course.
But when I connect to the OpenVPN server, I does not get a IP-address. Windows just set IP-address to the 169.xx.xx.xx address (local only)
I tried to make the TAP-adapter to have a static IP-address, xx.xx.xx.194 with xx.xx.xx.192 as gateway, and 255.255.255.0 as netmask.
Now I can't connect something with this IP. My computer tries to reach the destination with the TAP-adapter first, then it gives up and use my default network connection instead. (WLAN)
This is the config of OpenVPN server, do I miss something?
ifconfig xx.xx.xx.193 255.255.255.0
push "route xx.xx.xx.194 255.255.255.0 net_gateway"
push "route-gateway xx.xx.xx.192"
push "redirect-gateway def1"
push "dhcp-option DNS 220.127.116.11"
push "dhcp-option DNS 18.104.22.168"
keepalive 5 60
auth-user-pass-verify "/etc/openvpn/script/login.sh" via-env
I'm using MySQL authentication, so this is the login.sh script:
user_id=$(mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -sN -e "select user_id from ovpnuser where user_id = '$username' AND user_pass = '$password' AND user_enable=1 AND user_start_date != user_end_d$
[ "$user_id" != '' ] && [ "$user_id" = "$username" ] && echo "user : $username" && echo 'authentication ok.' && exit 0 || echo 'authentication failed.'; exit 1
This is connect.sh script:
##insert data connection to table log
mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -e "INSERT INTO ovpnlog (log_id,user_id,log_trusted_ip,log_trusted_port,log_remote_ip,log_remote_port,log_start_time,log_end_time,log_received,log_send) V$
##set status online to user connected
mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -e "UPDATE ovpnuser SET user_online=1 WHERE user_id='$common_name'"