OpenWrt Forum Archive

Topic: filesharing

The content of this topic has been archived on 13 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I have a WRT54GL with kamikaze. I am a beginner in openwrt, so maybe this is a very stupid question, but I just can't seem to get the solution by myself.
Because I am on a university network I have one cable coming out of the wall that gives me my internet and makes me able to fileshare with every other computer that is connected to this network. For me to have internet as well as acces to the local network I added this startup script:

/etc/rc.d/S48lanonwan

#!/bin/sh /etc/rc.common

START=48

start(){
include /lib/network
scan_interfaces

config_get WAN wan ifname
config_get LAN lan ifname
config_get WANDEV wan device
config_get WANTYPE wan proto

WANLAN=$(nvram get wan_also_masq_lan)


if [ $WANTYPE = "pppoe" -a $WANLAN = "on" ]; then
udhcpc -i $WANDEV -b -p /var/run/$WANDEV.pid -R

iptables -t nat -A zone_wan_nat -o $WANDEV -j MASQUERADE
iptables -A forwarding_lan -i $LAN -o $WANDEV -j ACCEPT
fi
}

However now I am not able to browse other computer connected to the local network. How do I need to configure openwrt so I can get internet and filesharing?

Not sure why you are doing what you are doing in the rc.local file.

Your setup really isn't unique. The cable coming out of your wall should just plug into the WAN port like you would if you were just connecting to a cable modem directly. Using the standard setup in /etc/config/networks you would obtain an IP address via DHCP (probably a 172. or 192. address) that would provide you access to the internet at large. Your private computers behind your router will need to have their own address space as to not clober with that of the universities. For instance if you get a 192 address from the university you can't have your address range be in the 192 as well or else the router will not forward requests correctly. You can probably fix this by modifying the routing table but the best route would be to have separate private address spaces.

Not sure what you're trying to do with the script either.

But, you said you want to be able to access file sharing on your university's network. That becomes difficult if you're using your OpenWrt device as a router (I don't want to go into the details: you have to find out all the ports/protocols used by said services, and forward them to your PC). You should use your device as a switch instead, or an access point (not a router) so your PC and all other devices have direct access to your university's network.

tamasrepus wrote:

Not sure what you're trying to do with the script either.

But, you said you want to be able to access file sharing on your university's network. That becomes difficult if you're using your OpenWrt device as a router (I don't want to go into the details: you have to find out all the ports/protocols used by said services, and forward them to your PC). You should use your device as a switch instead, or an access point (not a router) so your PC and all other devices have direct access to your university's network.

Not sure it really matters if he uses it as a router or not, he just needs to make sure he sub-nets the network space correctly. The switch on the OpenWRT device could have a 192. range and his university could be in the 172. range. Then the router would handle the routing to the 172 range. Pretty simple I think, but I may be wrong.

Thanks for your reactions and ofcourse a happy new year to all.

I can't just plug the cable in and set the wan to dhcp. True, i would get acces to other computers in the network, however I can't get internet because I manually need to use PPPoE with my student ID to get a connection through the internet. That's why i used the startup script. I set the WAN to PPPoE to make a connection to the internet and manually in the script fire up the DHCP client for the WAN in order to make a connection to the local network.

My router has 192 range, the local network is 172 and the internet gives me an ip in the 145 range. I tried to forward 137 through 139 and 445 ports, but i still can't see my roommates computer..

I have an image of the situation here: http://home.planet.nl/~vdongen/openwrt/diagram.jpg

jwvandongen wrote:

Thanks for your reactions and ofcourse a happy new year to all.

I can't just plug the cable in and set the wan to dhcp. True, i would get acces to other computers in the network, however I can't get internet because I manually need to use PPPoE with my student ID to get a connection through the internet. That's why i used the startup script. I set the WAN to PPPoE to make a connection to the internet and manually in the script fire up the DHCP client for the WAN in order to make a connection to the local network.

My router has 192 range, the local network is 172 and the internet gives me an ip in the 145 range. I tried to forward 137 through 139 and 445 ports, but i still can't see my roommates computer..

I have an image of the situation here: http://home.planet.nl/~vdongen/openwrt/diagram.jpg

Well that information would have been very helpful to have from the begining. I am not that familiar with PPPoE but I assume you set your WAN connection to PPPoE in the /etc/config/network. When you successfully connect, doesn't that initiate some sort of IP address assignment so that you don't need to run DHCP after that? If you don't run DHCP on the PPPoE connection, have the connection is made and that interface is brought up, what is the output of ifconfig for it?

When I succesfully connect I get an ipadres in the range of 145.x from the DHCP server at my university that gives me internet. I do need to run DHCP after that because otherwise I won't be able to get into the local network, the 172.x range.

Here is a more detailed schematics of our network. RM stands for RoomMate.

The weird thing is, at my current situation, I am able to telnet to a roommate in the 172.x range over the ports 139 and 445 (which I just opened), but I can't see them in explorer for filesharing..

+-------------+          +----------------+
| TU Network  |          | Complex switch |
| 145.x fixed | -------- | 172.x fixed    |
+-------------+          +----------------+
                           |       |
                           |       +----------------+
                           |       | WAN: 145.x     |  *
                           |       | WRT54GL        |
                         +-----+   | LAN: 192.168.x |
            172.x 145.x  | RM1 |   +----------------+
                         |-----|     \__ Desktop (192.168.x)  **
            172.x 145.x  | RM2 |     |__ Laptop (192.168.x)
                         |-----|     |__ ... (192.168.x)
            172.x 145.x  | RM3 |
                         |-----|
            172.x 145.x  | RMn |
                         +-----+

ifconfig:

br-lan    Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:181 errors:0 dropped:0 overruns:0 frame:0
          TX packets:223 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:18804 (18.3 KiB)  TX bytes:126773 (123.8 KiB)

eth0      Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:632 errors:0 dropped:0 overruns:0 frame:0
          TX packets:248 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:64497 (62.9 KiB)  TX bytes:131794 (128.7 KiB)
          Interrupt:4

eth0.0    Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:181 errors:0 dropped:0 overruns:0 frame:0
          TX packets:223 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:19528 (19.0 KiB)  TX bytes:127665 (124.6 KiB)

eth0.1    Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          inet addr:172.20.19.150  Bcast:172.20.19.255  Mask:255.255.252.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:371 errors:0 dropped:0 overruns:0 frame:0
          TX packets:31 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:28575 (27.9 KiB)  TX bytes:3346 (3.2 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ppp0      Link encap:Point-to-Point Protocol
          inet addr:145.94.20.185  P-t-P:145.94.1.0  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:4007 (3.9 KiB)  TX bytes:1602 (1.5 KiB)

(Last edited by jwvandongen on 3 Jan 2010, 14:21)

jwvandongen wrote:

When I succesfully connect I get an ipadres in the range of 145.x from the DHCP server at my university that gives me internet. I do need to run DHCP after that because otherwise I won't be able to get into the local network, the 172.x range.

Here is a more detailed schematics of our network. RM stands for RoomMate.

The weird thing is, at my current situation, I am able to telnet to a roommate in the 172.x range over the ports 139 and 445 (which I just opened), but I can't see them in explorer for filesharing..

+-------------+          +----------------+
| TU Network  |          | Complex switch |
| 145.x fixed | -------- | 172.x fixed    |
+-------------+          +----------------+
                           |       |
                           |       +----------------+
                           |       | WAN: 145.x     |  *
                           |       | WRT54GL        |
                         +-----+   | LAN: 192.168.x |
            172.x 145.x  | RM1 |   +----------------+
                         |-----|     \__ Desktop (192.168.x)  **
            172.x 145.x  | RM2 |     |__ Laptop (192.168.x)
                         |-----|     |__ ... (192.168.x)
            172.x 145.x  | RM3 |
                         |-----|
            172.x 145.x  | RMn |
                         +-----+

ifconfig:

br-lan    Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:181 errors:0 dropped:0 overruns:0 frame:0
          TX packets:223 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:18804 (18.3 KiB)  TX bytes:126773 (123.8 KiB)

eth0      Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:632 errors:0 dropped:0 overruns:0 frame:0
          TX packets:248 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:64497 (62.9 KiB)  TX bytes:131794 (128.7 KiB)
          Interrupt:4

eth0.0    Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:181 errors:0 dropped:0 overruns:0 frame:0
          TX packets:223 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:19528 (19.0 KiB)  TX bytes:127665 (124.6 KiB)

eth0.1    Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          inet addr:172.20.19.150  Bcast:172.20.19.255  Mask:255.255.252.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:371 errors:0 dropped:0 overruns:0 frame:0
          TX packets:31 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:28575 (27.9 KiB)  TX bytes:3346 (3.2 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ppp0      Link encap:Point-to-Point Protocol
          inet addr:145.94.20.185  P-t-P:145.94.1.0  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:4007 (3.9 KiB)  TX bytes:1602 (1.5 KiB)

So do you own what you have labeled the complex switch?

Since you can ping and such but not browse it is probably a NetBios thing. Your computers, in the 192. range are trying to browse the 172. network. Not sure how Netbios works but it probably is only scanning the 192 range and not the other.

A little confused what you said about the PPPoE setup. I would figure the connection from the switch to the TU network would need to be  initiated via PPPoE but everyone connected to that switch would then just use that connected as the default gateway. Not sure why you then need to run PPPoE on your OpenWRT device. Or maybe I am just not understanding the complete setup.

No, unfortunately I am not able to acces the complex switch.

I got this from the TU sites:

Network layout
ResNet is offered as a RJ-45 outlet in each room. 
This outlet is connected to a HP Procurve 2524 switch or a HP Procurve 5308 switch through UTP Cat 5(e) cabling. 
The supported protocols are Fast Ethernet and Ethernet (IEEE 802.3u and IEEE 802.3). 
On this ethernet segment a DHCP server (RFC 2131), a DNS server, a NTP server and a HTTP server are available. 
What is not available is a gateway to internet (except for multicast traffic). 
Further, a PPPoE Access Concentrators (RFC 2516) are available. 
The TU Delft operates an Access Concentrator under the name 'DePoort' offering the service 'TUdelft-FTTD'. 
All student and staff of TU Delft have a serviceaccount and can use that to log on to the TUdelft-FTTD' service. 
This service uses CHAP encryption.

I downloaded a portscanner and when I scan a roommate (172.x) from my laptop (192.x) I do see that the 139 port is open with him. On the otherhand when I portscan my router (172.x) from my roommate's computer (172.x) I see that only 22,53 and 80 are open. This is very strange since I do have forwarded(redirected) the 137-138,139 and 445 ports to my laptop..

(Last edited by jwvandongen on 4 Jan 2010, 02:02)

Here is what I think the problem is. Forget the PPPoE connection that you need so that you can access the network.

When you plug your OpenWRT device into the switch provided by your University, the WAN interface obtains a 172. IP address. Through that you can ping other roomates, etc that are connected to that switch.

You then plug in some additional computers you have to the ports on the OpenWRT device and they obtain a 192 address. The reason that file browsing probably isn't working is that those computers, when searching for devices that are sharing, send out a broadcast message. Broadcast messages are not transmitted to different networks so they never get routed to those other hosts in the 172 range.

You can probably do some firewall re-write rule to have broadcasts sent to 192.168.1.255 re-written to 172.x.255.255.

when I check ifconfig my eth0.1 already has a broadcast adress of 172.20.19.255. I just can't seem to get the br-lan's broadcast adress rewritten to 172.20.19.255. How do I need to create such a rule? just a normal portforwarding using iptables?

ifconfig

br-lan    Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2246 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2412 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:219847 (214.6 KiB)  TX bytes:1117417 (1.0 MiB)

eth0      Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:19580 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3238 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3016237 (2.8 MiB)  TX bytes:1263092 (1.2 MiB)
          Interrupt:4

eth0.0    Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2246 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2412 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:228831 (223.4 KiB)  TX bytes:1127065 (1.0 MiB)

eth0.1    Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          inet addr:172.20.19.150  Bcast:172.20.19.255  Mask:255.255.252.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17236 errors:0 dropped:0 overruns:0 frame:0
          TX packets:827 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2426470 (2.3 MiB)  TX bytes:116662 (113.9 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ppp0      Link encap:Point-to-Point Protocol
          inet addr:145.94.20.185  P-t-P:145.94.1.0  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:852 errors:0 dropped:0 overruns:0 frame:0
          TX packets:594 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:862771 (842.5 KiB)  TX bytes:92486 (90.3 KiB)

(Last edited by jwvandongen on 5 Jan 2010, 00:42)

jwvandongen wrote:

when I check ifconfig my eth0.1 already has a broadcast adress of 172.20.19.255. I just can't seem to get the br-lan's broadcast adress rewritten to 172.20.19.255. How do I need to create such a rule? just a normal portforwarding using iptables?

ifconfig

br-lan    Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2246 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2412 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:219847 (214.6 KiB)  TX bytes:1117417 (1.0 MiB)

eth0      Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:19580 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3238 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3016237 (2.8 MiB)  TX bytes:1263092 (1.2 MiB)
          Interrupt:4

eth0.0    Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2246 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2412 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:228831 (223.4 KiB)  TX bytes:1127065 (1.0 MiB)

eth0.1    Link encap:Ethernet  HWaddr 00:25:9C:41:F3:86
          inet addr:172.20.19.150  Bcast:172.20.19.255  Mask:255.255.252.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17236 errors:0 dropped:0 overruns:0 frame:0
          TX packets:827 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2426470 (2.3 MiB)  TX bytes:116662 (113.9 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ppp0      Link encap:Point-to-Point Protocol
          inet addr:145.94.20.185  P-t-P:145.94.1.0  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:852 errors:0 dropped:0 overruns:0 frame:0
          TX packets:594 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:862771 (842.5 KiB)  TX bytes:92486 (90.3 KiB)

To be honest I don't know. Maybe check http://wiki.openwrt.org/doc/uci/firewall and do a redirect or rule to transfer traffic destined for 192.168.1.255 to the broadcast for 172. The only thing you will need to worry about is how OpenWRT sets these up. I don't have it on hand right now but I once found a great diagram that shows where each chain takes place in the processing. Obviously this rule would have to be in a chain that is prior to routing or else it won't work (if I am mistaken please, someone with better knowledge correct me).

Oh, and if I understand what you were trying to say. I don't think you can set the broadcast address for br-lan to 172.20.19.255 as it is not part of that network.

(Last edited by cyrus_mc on 5 Jan 2010, 01:31)

The discussion might have continued from here.