Update files in USB using Internet

Posted by abhaym 
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Now, this forum is in read-only mode. You find details Details hereContinue on /r/PirateBox
Update files in USB using Internet
October 14, 2013 06:40AM
Hi,

I wanted to update files at specific time of the day in my USB using internet.

For e.g. at 7 PM Daily My USB will get synched with the server using internet.

Can you tell me how to achive that in Piratebox ? Any refernces ?
Re: Update files in USB using Internet
October 14, 2013 06:24PM
No references as far as I know.

Do you have an OpenWRT System or something else? On RPi it is a bit easier, because the wifi is not bridged with the ethernet-port. On OpenWRT, you have to break up the bridge, to be sure the PirateBox-Users don't have access to your local lan... and the existing DHCP Server are not interfere.
Re: Update files in USB using Internet
October 15, 2013 06:45AM
I am using OpenWrt on TP-Link MR3020.

Can you tell me how to break the bridge so i can connect to the internet directly. Without change in network file.
Re: Update files in USB using Internet
October 15, 2013 07:59PM
nope, you can't break up the bridge without changing the network file. Doing that will have a huge impact on your configuration... I recommend the following only, If you know that your PirateBox is working over wifi and you tested how to get into the box via failsave-mode and change configurations. [github.com]

modify your /etc/config/network
that it looks similar to that


config interface 'loopback'
   option ifname 'lo' 
   option proto 'static'
   option ipaddr '127.0.0.1'
   option netmask '255.0.0.0'

config interface 'lan'
   option type 'bridge'
   option proto 'static'
   option netmask '255.255.255.0'
   option ipaddr '192.168.1.1'

config interface 'wan'
    option ifname 'eth0'  
    option proto 'dhcp'

So, that should work in any case where your piratebox is connected via wire and your homenetwork is not 192.168.1.x
If you want to failsafe now, it still works via ethernet. Everything else has to be done via wifi.

Maybe you need to change firewall config, but we will come back to that later.

After that, you might still have to run /etc/init.d/piratebox nodns .. but that is quite unspecific, when you have to. To avoid that unclear status, edit /etc/piratebox.common and find the following line
pb_use_local_dns="yes"
Switch that to no and that should enable your box to do valid dns requests on the internet.

Test your internet connections with
ping -n 2 google.com
ping -n 2 8.8.8.8

Yeah, that should work.. somehow.

In any case, please come back and ask. About the sync script, we talk later after we are sure internet is working.

regards Matthias

OpenWRT network configuration
Re: Update files in USB using Internet
October 22, 2013 09:59AM
Thanks for the Steps.

Now i am connecting to the internet using Piratebox WIFI.

But now i have one website hosted inside piratebox which is accessed by Mobile devices using WIFI.

I want to log the count inside the Piratebox and then post to the Server using internet.But now all my devices are connected to the internet and not able to redirect to the Piratebox website.

So can i enable the internet for inside activites in the piratebox and block for all the devices which are connected to the Piratebix WIFI.
Re: Update files in USB using Internet
October 22, 2013 05:20PM
abhaym Wrote:
-------------------------------------------------------
> Thanks for the Steps.
>
> Now i am connecting to the internet using
> Piratebox WIFI.
>
> But now i have one website hosted inside piratebox
> which is accessed by Mobile devices using WIFI.
>
> I want to log the count inside the Piratebox and
> then post to the Server using internet.But now all
> my devices are connected to the internet and not
> able to redirect to the Piratebox website.
>
> So can i enable the internet for inside activites
> in the piratebox and block for all the devices
> which are connected to the Piratebix WIFI.

Are you sure you configured everything like described? In my mind, you still won't get any dns resolution with getting back normal IP addresses like google.com
You maybe need to disable forward in the firewall, but the still, dns shouldn't work.

Can you please post the /etc/config/network , /etc/config/wireless and /opt/piratebox/conf/piratebox.conf ?

Matthias
Re: Update files in USB using Internet
October 23, 2013 07:28AM
Below are the Files.When i connect my Box with Ethernet cable my external request are root to the internet.

Let me know is anything i need to modify in below files ?

*****Netwrok ******
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'

config interface 'lan'
option ifname 'eth0'
option type 'bridge'
option proto 'static'
option netmask '255.255.255.0'
option gateway '192.168.1.1'
list dns '192.168.1.1'
list dns '8.8.8.8'
option ipaddr '192.168.1.1'
**********************************
****Wireless***********************
config wifi-device 'radio0'
option type 'mac80211'
option channel '11'
option hwmode '11ng'
option path 'platform/ar933x_wmac'
option htmode 'HT20'
list ht_capab 'SHORT-GI-20'
list ht_capab 'SHORT-GI-40'
list ht_capab 'RX-STBC1'
list ht_capab 'DSSS_CCK-40'
option disabled '0'

config wifi-iface
option device 'radio0'
option network 'lan'
option mode 'ap'
option encryption 'none'
option ssid 'MYBOX'

**********************************
*******piratebox.conf**********


#----------------- Folder Configuration -------------------#

PIRATEBOX_FOLDER="/opt/piratebox"
WWW_FOLDER="/opt/piratebox/www"

#Do not change untill really needed.
PIRATEBOX_PYTHONPATH="$PIRATEBOX_FOLDER/python_lib"


#Datafolder , where is you usb-stick // drive mounted
SHARE_FOLDER="$PIRATEBOX_FOLDER/share"

#Upload Folder
# Change this if you want to user uploaded data in a subfolder
# Make sure the folder exists
# UPLOADFOLDER="$SHARE_FOLDER/Upload"
UPLOADFOLDER="$SHARE_FOLDER/Shared"

#----------------- Startup Configuration -------------------#
# Which Steps has to be done

#Do network config
DO_IFCONFIG="no"

#Do IW config - setting up a wlan0 interface with iw
# for some wifi-cards required
DO_IW="no"
#Iw physical interface
PHY_IF="phy0"

# Check if interface exists
# should be set to yes if you use a USB wifi card
PROBE_INTERFACE="no"
# wait how many seconds until throw an error
PROBE_TIME=10

#Start services...
# act like a apn / <yes|no>
# please have a look @ hostapd.conf ; you may need to change some options, regarding wifi-card
USE_APN="no"
# act like dns&dhcp (dnsmasq)
USE_DNSMASQ="yes"

#HOSTNAME ... if you really want to change it, plz change:
# bin/droopy
# conf/hosts
HOST="mybox.mobi"


#Option for enabling special checks under openwrt
OPENWRT="yes"

#----------------- Configuration for DNSMASQ & IF-Setup -------------------#
# Name of the wlan interface
INTERFACE="wlan0"
# On which interface DNSMASQ should listen. -i is the parameter for dnsmasq
# Make it empty to disable
DNSMASQ_INTERFACE="br-lan"

#Brdige add interfacce (setr yes to enable bridging)
DO_BRIDGE="no"
BRIDGE="br-lan"

#Network
NET=192.168.1

#IP-SHORT (is stringed together)
# Which IP is your Box?? i.e. 1 => 192.168.1.1
IP_SHORT=1

#DHCP LEASE Start
START_LEASE=10
#DHCP LEASE End Range
END_LEASE=250
#Leasetime (When should the client renew it's IP)
LEASE_DURATION=12h

# Define the netmask
NETMASK=255.255.255.0

#SET IP for ifconfig stuff - DON'T CHANGE
IP=$NET.$IP_SHORT

#Load Config about ipv6 stuff - DON'T CHANGE
. $PIRATEBOX_FOLDER/conf/ipv6.conf


#----------------- Configuration for the pure piratebox -------------------#
## droopy, webserver, shoutbox- and forum-server


#Start droopy? - Enable upload?
DROOPY_ENABLED="yes"
#Image-SRC
IMAGENAME="piratebox-logo-small.png"
IMAGE="$PIRATEBOX_FOLDER/src/$IMAGENAME"
DROOPY_TXT=""
DROOPY_PORT="8080"
DROOPY_USERDIR=""
# Uncomment line below for adding directory feature
#DROOPY_USERDIR=" -u True "

#Use UserId from lighttpd for droopy (use on ext-filesystems)
DROOPY_USE_USER="no"

#Configuration for chat (If you decide to move the chat folder, you have to change /opt/piratebox/chat/cgi-bin/py* files )
CHATFILE="$WWW_FOLDER/cgi-bin/data.pso"

#Generated File
GEN_CHATFILE="$WWW_FOLDER/chat_content.html"

# Reset Shoutbox on Startup?
RESET_CHAT="yes"

#Inititiation Chat-Message
CHATMSG="<date>00:00:00</date>&nbsp;&nbsp;<name>PirateBox:</name>&nbsp;&nbsp;&nbsp;<data class='def'>Chat and share files anonymously!</data><br>"

#Activate Global chat
# Still experimentall!
GLOBAL_CHAT="no"

#On which broadcast address should it send
# Take care on the syntax!!
GLOBAL_DEST="[ #255.255.255.255# , #10.255.255.255# , #$NET.255# ]"

#------------------------ Additional configuration for lighttpd
LIGHTTPD_USER=nobody
LIGHTTPD_GROUP=nogroup


#------------------------ Hook in user-config
. $PIRATEBOX_FOLDER/conf/hook_custom.conf
Re: Update files in USB using Internet
October 23, 2013 01:40PM
Hi,
it seems you haven't followed my instructions about dividing your piratebox-network and your homenetwork.
If the network is bridged, the dhcp server from your homenetwork interferes with the piratebox-dhcp server, which results in a not stable setup for further steps.
The internet access may work, but the piratebox.lan dns won't resolve, for example.

Matthias
Hi Matthias,

we have done the settings which you have told us. but we are able to access internet through WIFI connected devices. we wated to restrict user to use internet through wifi. And router should get connected to internet internally and internet should not be shared to any user who connects through WIFI.

Thanks
Ashish
Re: Update files in USB using Internet
October 28, 2013 09:40PM
Hi Abhay and Ashish,
I understand, but the posted network-config is wrong. In the posted network config above, you still are using a bridged Wifi-lan setup, which you can't regulate in any case. A bridge network connection is literaly a bridge between the wired and the wireless interface.

Bridged-Networks ; wikipedia

In your setup, you want to separate interface. The first is the wired ethernet connection, which you can hook up to a router with internet. The second one is the wifi-network only for the PirateBox-like services, which is separated. Maybe you need to disable the FOWARD setup in etc/config/firewall to avoid forwarding traffic, but that are the fine-tune-adjustments.

Back to the network config, it should look like this to separate the two interfaces from each other


config interface 'loopback'
   option ifname 'lo' 
   option proto 'static'
   option ipaddr '127.0.0.1'
   option netmask '255.0.0.0'

config interface 'lan'
   option type 'bridge'
   option proto 'static'
   option netmask '255.255.255.0'
   option ipaddr '192.168.1.1'

config interface 'wan'
    option ifname 'eth0'  
    option proto 'dhcp'

That would, in my idea, the wifi-network only to br-lan containing only wlan0 with the static setup.
On the wired-network (ethernet) port, you have a normal dhcp given address from your home-network. Attention: Your home-network should be something different then 192.168.1.x (or change the IP of the piratebox, see: [piratebox.aod-rpg.de] )
So your PirateBox itself should be able to ping IPs in the internet. The wired connected clients shouldn't be able to ping 8.8.8.8 through wifi&piratebox down to that IP.

Further readings on openwrt config firewall-config network-config

hope that helps to make the first step
Matthias
Dear Matthias,

with settings which u have given we have changed those settings similarly in router but we are not able to identify whether internet is connected internally in router. and when we ping Google.com it showing deafault ip add of router i.e. 192.168.1.1 so we are not getting that internet is connected internally or not. we have changed redirection settings to this ip add do u think this could be the problem for ping request?

Regards,
Ashish
Re: Update files in USB using Internet
November 06, 2013 09:15PM
Hi Ashish,
try to ping a fixed IP first, like 8.8.8.8
normally, every nameresolution request is redirected within the piratebox to the piratebox itself... adn that always deliver 192.168.1.1

to disable this behaviour run:

/etc/init.d/piratebox nodns

best wishes
Matthias
HI Matthias,

we have tried to ping 8.8.8.8 but this ip is not giving any response.
Re: Update files in USB using Internet
November 07, 2013 04:01PM
hi!
what IP range is your home network ?

regards Matthias
Hi Matthias,

Our hone network range is 192.168.0.1 and 192.168.9.1

Regards,
Ashish
Re: Update files in USB using Internet
November 10, 2013 05:06PM
If I have time in the next couple of weekends (I already have one in sight) I'll try this setup and report back.
I still assume that the configuration like this should work out, but maybe I'm missing a key point about all this stuff.
Matthias,

please let us know whenever u have a time. we have to do this change.

Regards,
Ashish
Re: Update files in USB using Internet
January 23, 2014 09:57PM
Hi,
I wrote a small howto here:
[forum.daviddarts.com]

maybe that helps
Matthias