terça-feira, junho 28, 2011

DD-WRT Dual / Triple WAN HowTo 3g/hsdpa connection

Here are steps a follow
http://www.dd-wrt.com/phpBB2/viewtopic.php?t=13869&postdays=0&postorder=asc&start=795
nvram set vlan0ports="3 2 1 5*"
nvram set vlan1ports="4 5"
nvram set vlan2ports="0 5"
nvram set vlan2hwname=et0
nvram set wan_ifname=ppp0
nvram commit

change from web console

script this is for fixed ip, to dhcp change to use udhcpc with the script bellow...

wan2.firewall
#!/bin/sh

WAN2_IFNAME=vlan2
WAN2_IPADDR=192.168.1.2
WAN2_BROADCAST=192.168.1.255
WAN2_GATEWAY=192.168.1.1
WAN2_NETMASK=255.255.255.0

if [ "$(nvram get wan2_ipaddr)" != "$WAN2_IPADDR" ]; then
nvram set wan2_ifname=$WAN2_IFNAME
nvram set wan2_ipaddr=$WAN2_IPADDR
nvram set wan2_gateway=$WAN2_GATEWAY
nvram set wan2_netmask=$WAN2_NETMASK
nvram set wan2_broadcast=$WAN2_BROADCAST
nvram commit
fi

ifconfig $(nvram get wan2_ifname) $(nvram get wan2_ipaddr) netmask $(nvram get wan2_netmask) broadcast $(nvram get wan2_broadcast) up

Then,

cd /jffs/
wget http://www.jbarbieri.net/dd-wrt/scripts/iptables
cd /jffs/scripts/
wget http://www.jbarbieri.net/dd-wrt/scripts/firewall.firewall
wget http://www.jbarbieri.net/dd-wrt/scripts/routes.firewall
wget http://www.jbarbieri.net/dd-wrt/scripts/udhcpc-wan2.script

chmod 755 /jffs/iptables
chmod 755 /jffs/scripts/*

nvram set rc_startup='udhcpc -i vlan2 -p /var/run/udhcpc.pid -s /jffs/scripts/udhcpc-wan2.script
/jffs/scripts/firewall.firewall
/jffs/scripts/routes.firewall'

nvram set rc_firewall='/jffs/scripts/routes.firewall
/jffs/scripts/firewall.firewall'
nvram commit
reboot
------------------
The steps bellow is a work arround for routers (like mine) that cant mount any volume and do not have jffs support.

Using web dd-wrt go to Administration -> Commands
Paste de code bellow

echo "if [ ! -f /tmp/init.sh ]; then" > /tmp/get_init.sh
echo " echo \"get file init.sh on http://www.rc1.com.br/dd-wrt-scripts/init.sh\"" >> /tmp/get_init.sh
echo " /usr/bin/wget -O /tmp/init.sh http://www.rc1.com.br/dd-wrt-scripts/init.sh" >> /tmp/get_init.sh
echo "#else" >> /tmp/get_init.sh
echo "# echo \"file init.sh exist\"" >> /tmp/get_init.sh
echo "fi" >> /tmp/get_init.sh

click Save Startup

go to Administration -> Management
Enable Cron
Paste de code bellow to cron box
*/2 * * * * root /bin/sh /tmp/get_init.sh >> /var/log/messages 2>>/var/log/messages
*/3 * * * * root /bin/sh /tmp/init.sh >> /var/log/messages 2>>/var/log/messages

What is does is download all files from web and run them every 3 minutes

segunda-feira, junho 20, 2011

Cellular Phone/USB Modem as WAN connection with DD-WRT

Good article on scripting DD-WRT USB Modem for 3g hspda connection, associated with fail over scripts might bring good alternative.