WildWurger
Occasional Visitor
Hi RMerlin and all the experts,
I need some help on getting understanding and getting things work. but before anything i would like to thanks RMerlin for such a great firmware. I am very newbie in linux and starting to learn bit by bit, please bear with me...
i have some special requirement on my internet connection...
basically what i trying to achieve is :-
1) connect to internet via pppoe (dynamic ip)
2) connect to vpn (static ip)
- that way i get 2 ip for my services
3) trying to use openvpn-event to do selective routing, basically i want to route some selective destination (like all China ip) and some selective source ip (some server)
- not all shown in the script below as i need to key in all the destination ip one by one
4) after connected to VPN, port forwarding selectively to a) WAN b) VPN
firmware version is 3.0.0.4.374.35_4
so far, i can get 1) and 2) working no problem (is there anyway to even use 2 vpn clients?) or for that matter even 3 (with PPTP).
so 3) is not working as i expected. i got jffs/scripts folder setup and had openvpn-event chmod to 777 but when connected to VPN, the scripts wont run. 000wanstarted also wont show in /tmp. I tried not use wan-start, as i want to manually control the up and down of the vpn myself. (as in once i connect VPN this script is to run, when disconnect from VPN, it will return back to before-script state)
my scripts (also many thanks to this forum, i copy paste and modify to suite my need, thank you to whoever that share the scripts and their expertise)
and 4) after i connected to VPN and after the script works as expected, how to do selective port forwarding, for example
a) port 443 to be forward to WAN
and
b) port 443 forward to be forward to VPN at the same time.
* Note, I also have many different subnets under my primary router subnet, which already set up using routing, therefore for the port forwarding and selective routing, i will also ended up using alot different private ip address.
Please help me and thank you very much in advance. It may seems that i asked alot as i love to create challenge and my testing lab to work on (therefore i need multiple ip addresses)
I need some help on getting understanding and getting things work. but before anything i would like to thanks RMerlin for such a great firmware. I am very newbie in linux and starting to learn bit by bit, please bear with me...
i have some special requirement on my internet connection...
basically what i trying to achieve is :-
1) connect to internet via pppoe (dynamic ip)
2) connect to vpn (static ip)
- that way i get 2 ip for my services
3) trying to use openvpn-event to do selective routing, basically i want to route some selective destination (like all China ip) and some selective source ip (some server)
- not all shown in the script below as i need to key in all the destination ip one by one
4) after connected to VPN, port forwarding selectively to a) WAN b) VPN
firmware version is 3.0.0.4.374.35_4
so far, i can get 1) and 2) working no problem (is there anyway to even use 2 vpn clients?) or for that matter even 3 (with PPTP).
so 3) is not working as i expected. i got jffs/scripts folder setup and had openvpn-event chmod to 777 but when connected to VPN, the scripts wont run. 000wanstarted also wont show in /tmp. I tried not use wan-start, as i want to manually control the up and down of the vpn myself. (as in once i connect VPN this script is to run, when disconnect from VPN, it will return back to before-script state)
my scripts (also many thanks to this forum, i copy paste and modify to suite my need, thank you to whoever that share the scripts and their expertise)
Code:
#!/bin/sh
logger -t "($(basename $0))" $$ OpenVPN Selective Customization Starting... " $0${*:+ $*}."
touch /tmp/000wan-started
for i in /proc/sys/net/ipv4/conf/*/rp_filter ; do
echo 0 > $i
done
ip route flush table 100
ip route del default table 100
ip rule del fwmark 1 table 100
ip route flush cache
iptables -t mangle -F PREROUTING
tun_if="tun11"
ip route show table main | grep -Ev ^default | grep -Ev $tun_if \
| while read ROUTE ; do
ip route add table 100 $ROUTE
logger -t "($(basename $0))" $$ OpenVPN Table 100 added entry: $ROUTE
done
ip route add default table 100 via $(nvram get wan0_gateway)
ip rule add fwmark 1 table 100
ip route flush cache
iptables -t mangle -A PREROUTING -i br0 -j MARK --set-mark 1
iptables -t mangle -A PREROUTING -i br0 -m iprange --dst-range 78.31.8.1-78.31.15.254 -j MARK --set-mark 0
iptables -t mangle -A PREROUTING -i br0 -m iprange --dst-range 8.8.4.4 -j MARK --set-mark 0
iptables -t mangle -A PREROUTING -i br0 -m iprange --src-range 10.0.1.70 -j MARK --set-mark 0
logger -t "($(basename $0))" $$ OpenVPN Selective Customization completed.
and 4) after i connected to VPN and after the script works as expected, how to do selective port forwarding, for example
a) port 443 to be forward to WAN
and
b) port 443 forward to be forward to VPN at the same time.
* Note, I also have many different subnets under my primary router subnet, which already set up using routing, therefore for the port forwarding and selective routing, i will also ended up using alot different private ip address.
Please help me and thank you very much in advance. It may seems that i asked alot as i love to create challenge and my testing lab to work on (therefore i need multiple ip addresses)
Last edited: