I want to check that the ip is present within the ccd folder and push the ip route to the FORWARDING chain in the iptables. Im new to bash scripting and need a little help finishing this script.
client file in /etc/openvpn/ccd :
ifconfig-push 10.8.0.45 255.255.255.0
push 'route 10.10.0.45'
I need to grep 10.8.0.45 & 10.10.0.45
and push those routes in the iptables. e.g
iptables -A FORWARD -s 10.8.0.45 -d 10.10.0.45 -j ACCEPT
client-connect /etc/openvpn/on_connect.sh
script I need help with 'grep' or 'awk'
static_ip= grep "^push \"route" | grep "^'" | cut -f2 -d" "
ip_destination=grep "^push \"route" | grep "^'" | cut -f3 -d" "
#!/usr/bin/env bash # # Add iptables rules based on CCD client config. # CCD_DIR="/etc/openvpn/ccd" # iptables rule comment - the disconnect script will # remove all strings matching this pattern RULE_COMMENT="OVPN_"$common_name static_ip=grep.. ip_destination=grep.. if [ -f $CCD_DIR/$common_name ]; then sudo iptables -A FORWARD -s $static_ip -d ip_destination -j ACCEPT fi exit 0