Init-b-out-ba paket¶
- Sadržaj
- Init-b-out-ba paket
Sadržaj init-b-out-ba paketa¶
root@router-wan-sa-1:/# ipkg files init-b-out-ba
Package init-b-out-ba (0.0.3-1) is installed on root and has the following files: /etc/init.d /etc/init.d/init-b-out-ba
Karakteristike init-b-out-ba skripte¶
init-b-out-ba skripta radi sljedeće:- ako firmware tek inicijaliziran vrši auto recovery proceduru
- mount-a /mnt/1 shfs, ako su shfs varijable setovane
- pokreće mrežnu init skriptu /mnt/1/etc/init.d/init-b-out-ba, ako postoji
- uobičajeno, mrežna init skripta kopira u /tmp/
- firewall - <hostname>.fw
- router.sh - inicijalizacija route-a
- još jednom restartuje wan konekciju
- za bihnet: restartuje freezone, koja opet refreshira i glavnu wan-bihnet konekciju
- uobičajeno, mrežna init skripta kopira u /tmp/
Podešenja /etc/hotplug.d/iface¶
Ovo su skripte koje se pokreću prilikom podizanja wan interfejsa
hotplug.d/iface firewall¶
/etc/hotplug.d/iface/09-firewall
. /etc/functions.sh config_cb() { if [ "$1" == "system" ] ; then SECTION=$2 fi } config_load system config_get HOSTNAME $SECTION hostname COMMAND=/tmp/${HOSTNAME}.fw [ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && { [ -x $COMMAND ] && { $COMMAND 2>&1 } & }
hotplug.d/iface routes¶
router.sh se pokreće svaki put nakon ifup wan-a
/etc/hotplug.d/iface/10-routes1
COMMAND=/tmp/routes.sh [ -x $COMMAND ] && { $COMMAND 2>&1 } & return 0
routes.sh¶
Kao najbitnije, routes.sh setuje freezone route
/mnt/1/routes.sh
#!/bin/sh IP_WAN=`ifconfig ppp0 | grep -o "inet addr:\(.*\) P-t-P" | sed -e "s/inet addr://" | sed -e "s/ P-t-P//" | sed -e "s/ //g"` echo ipwan=$IP_WAN add_route() { local net=$1 local via=$2 local dev=$3 echo $net, $dev # if you say: # ip route add 195.222.33.151 dev ppp0 # then ip route show => # 195.222.33.151 dev ppp0 scope link if [ "$via" == "link" ] then ROUTE_EXISTS=`ip route show | grep -c "$net dev $dev.*link"` else ROUTE_EXISTS=`ip route show | grep -c "$net via $via dev $dev"` fi #echo net=$net, via=$via, dev=$dev, exists=$ROUTE_EXISTS if [ "$ROUTE_EXISTS" == "0" ] then if [ "$via" == "link" ] then echo ip route add $net dev $dev ip route add $net dev $dev else echo ip route add $net via $via dev $dev ip route add $net via $via dev $dev fi fi } VPN_ROUTER="192.168.45.5" add_route "195.222.0.0/16" "10.0.0.1" "ppp1" add_route "195.222.33.151" "link" "ppp0" add_route "80.65.85.0/24" "10.0.0.1" "ppp1" add_route "192.168.11.0/24" $VPN_ROUTER "br-lan" add_route "192.168.65.0/24" $VPN_ROUTER "br-lan" add_route "192.168.66.0/24" $VPN_ROUTER "br-lan" add_route "192.168.42.0/24" $VPN_ROUTER "br-lan" add_route "192.168.43.0/24" $VPN_ROUTER "br-lan" add_route "192.168.44.0/24" $VPN_ROUTER "br-lan" add_route "192.168.55.0/24" $VPN_ROUTER "br-lan" add_route "192.169.45.0/24" "192.168.45.4" "br-lan"
1 originalna openwrt image sadrži 10-routes skriptu koja čita, flash/uci varijable, kako se sa tim podešenjima nisam snašao napravio sam router routes.sh koja se pokreće