skyfly555
Posts: 8
Joined: Fri Nov 27, 2015 12:46 pm

Trying to use a RPI 2 B as a router with 2 NICs - impossible

Sun Dec 13, 2015 3:46 pm

Hello, friends.

I wonder if somebody has got this working. My RPI 2 B, hangs out after 2 or 3 minutes, just after 3-4 DNS queries, it gets disconnect from eth0 and eth1 and I have to hard-reboot.

I've tried tones of options, last I tried is this, and it's supposed to work: http://qcktech.blogspot.co.uk/2012/08/r ... outer.html

I try to have eth0-internal connected to the modem-adsl-router at home, and connecting other computers at home to the RPI to eth1 (USB ASIX 88772 Ethernet Adapter, compatible out-of-the-box with RPI and RPI 2. The goal: Having my RPI2 being my router-firewall-DHCP server-DNS server-squid proxy-dansguardian filter.

Steps I've done:
1- su
2- nano /etc/network/interfaces

Code: Select all

auto lo 
iface lo inet loopback  

#Onboard NIC connecting to the Internet 
auto eth0 
iface eth0 inet dhcp  

#USB NIC serving as internal gateway 
auto eth1 
iface eth1 inet static 
address 192.168.50.1 
netmask 255.255.255.0 
network 192.168.50.0 
broadcast 192.168.50.255
gateway 192.168.50.1
2- sudo apt-get update
sudo apt-get install dnsmasq
nano /etc/dnsmasq.conf

Code: Select all

filterwin2k
no-resolv
server=87.216.1.65
server=87.216.1.66
interface=lo
interface=eth1
expand-hosts
domain=local
dhcp-range=192.168.50.100,192.168.50.150,255.255.255.0,12h
dhcp-option=3,192.168.50.1
dhcp-authoritative
3- sudo echo 1 > /proc/sys/net/ipv4/ip_forward
nano /etc/sysctl.conf
Uncomment line: net.ipv4.ip_forward=1
4- iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables-save > /etc/iptables.up.rules
5- Create a script sudo nano /etc/network/if-pre-up.d/iptables

Code: Select all

#!/bin/sh

#This script restores iptables upon reboot  
iptables-restore < /etc/iptables.up.rules  

exit 0
Change ownership and permissions of the script so it will run at boot.

sudo chown root:root /etc/network/if-pre-up.d/iptables
sudo chmod +x /etc/network/if-pre-up.d/iptables
sudo chmod 755 /etc/network/if-pre-up.d/iptables
6- Reboot.
7- Check iptables is persistent: iptables –t nat -L
8- Connect a computer to eth1 (USB ASIX 88772).
9- In a Terminal ping 8.8.8.8 just to see when RPI2B hangs.
10- After browsing two or three webpages, pings don't respond, and you cannot access to RPI2B with SSH, not from 192.168.1.x (connected to eth0-onboard LAN) neither from 192.168.50.1 (connected to eth1-USB LAN).

Please, can you help me? Am I doing something wrong? Is there any routing bug on RPI 2B?

I'm asking this last question because Michael Tremer, a main developer of IPFire distribution says about the Raspberry Pi 2 that it's not very good for routing, and Arne.F, another core developer, talks about this, too, in http://forum.ipfire.org/viewtopic.php?t=12541

Thank you, than you very much!!

skyfly555
Posts: 8
Joined: Fri Nov 27, 2015 12:46 pm

Re: Trying to use a RPI 2 B as a router with 2 NICs - imposs

Sun Dec 13, 2015 10:12 pm

Hi, I've tried the same on my RPi 1 B and connected it to a TV (until now just using SSH).

When it hangs, the screen says:
kernel BUG at /net/core/skbuff.c:102!
Internal error: Oops - BUG: 0 [#1] PREEMPT ARM
detall-bug.jpg
I think it's related to the USB NIC I'm using, isn't it?

Thank you,

ejolson
Posts: 6317
Joined: Tue Mar 18, 2014 11:47 am

Re: Trying to use a RPI 2 B as a router with 2 NICs - imposs

Sun Dec 13, 2015 11:31 pm

skyfly555 wrote:Hi, I've tried the same on my RPi 1 B and connected it to a TV (until now just using SSH)
I've used the Pi 2B reliably as a router. The upstream comes in over a WiFi USB dongle and the system area network is connected to the 100BT built in. Masquerade NAT, dhcp, bind, ipsec and VPN tunnels through ssh all work fine.

Could your problem be not hefty enough power supply? Also, have you tried slowing the upstream to 10 mbps?

skyfly555
Posts: 8
Joined: Fri Nov 27, 2015 12:46 pm

Re: Trying to use a RPI 2 B as a router with 2 NICs - imposs

Mon Dec 14, 2015 6:08 am

Thank you, ejolson.

I'm using the official Raspberry Pi power supply (5V 2A), and I'm connecting the USB ethernet adapter to a 10 Mbps 5-port ethernet hub.

Now, I'm using the USB adapter with the image of a man called ElWilliaM - in this forum (viewtopic.php?f=29&t=24557) two years ago, and it works like a charm.

This is the image he shared in that forum:
https://www.dropbox.com/s/uq4ezoq2hurn6 ... ha2.img.7z

So, I suppose that the version he's using of Raspbian (or firmware?) doesn't have the bug that the actual version of Raspbian has. Can this supposition be correct?

Or maybe I'm simply forgetting some code lines into iptables, dnsmasq, interfaces config, or whatever?

User avatar
allfox
Posts: 452
Joined: Sat Jun 22, 2013 1:36 pm
Location: Guang Dong, China

Re: Trying to use a RPI 2 B as a router with 2 NICs - imposs

Mon Dec 14, 2015 7:21 am

Greetings.

I'm on an almost same setup as OP: On board NIC to internet, and an AX88772B to LAN. I used this for 2 years. It works on an old Pi B and the new Pi 2.

I read OP's setup, the /etc/network/interfaces is not right. That's the old way (although I think it's right). New Raspbian need you set all the NIC to manual instead of dhcp nor static. Mine:

Code: Select all

  1 # Please note that this file is written to be used with dhcpcd.
  2 # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'.
  3
  4 auto lo
  5 iface lo inet loopback
  6
  7 allow-hotplug eth0
  8 iface eth0 inet manual
  9
 10 allow-hotplug eth1
 11 iface eth1 inet manual
 12
 13 auto dsl-provider
 14 iface dsl-provider inet ppp
 15 pre-up /bin/ip link set eth0 up # line maintained by pppoeconf
 16 provider dsl-provider
See the first 2 lines there? For a static IP on eth1, edit /etc/dhcpcd.conf, append something like mine:

Code: Select all

 44 interface eth1
 45 static ip_address=192.168.2.26/24
 46 static routers=192.168.2.26
 47 static domain_name_servers=192.168.2.26
And please make sure power supply is sufficient. If the only thing that connecting to Pi is the AX88772B, I think adding max_usb_current=1 to /boot/config.txt is OK.

Forget about those words about Pi's USB is slow. Pi's bottleneck is CPU. When transfer file on an encrypted channel, Pi would be slow, because this need CPU to do crypto math. With a naked channel, Pi 2B able to reach the full speed of 100Mbps, that is about 11+ mega bytes per second.

User avatar
allfox
Posts: 452
Joined: Sat Jun 22, 2013 1:36 pm
Location: Guang Dong, China

Re: Trying to use a RPI 2 B as a router with 2 NICs - imposs

Mon Dec 14, 2015 9:18 am

I find someone with NIC from Davicom would meet the skbuff.c problem: viewtopic.php?t=34557&p=674610

That chip is known to not work. It is advertised as 100MB however it's USB 1.1.

AX88772B or AX88179 should work perfectly.

skyfly555
Posts: 8
Joined: Fri Nov 27, 2015 12:46 pm

Re: Trying to use a RPI 2 B as a router with 2 NICs - imposs

Mon Dec 14, 2015 11:53 am

Thank you very much, Allfox.

Tomorrow (I'll have time enough) I'll try to get your config working, I'll forget using dnsmasq and I'll use isc-dhcp-server as you say.

Very grateful for your comments,

skyfly555
Posts: 8
Joined: Fri Nov 27, 2015 12:46 pm

Re: Trying to use a RPI 2 B as a router with 2 NICs - imposs

Mon Dec 14, 2015 11:54 am

In this very moment, I've added max_usb_current=1 to /boot/config.txt and rebooted and it seems to work better. It's not hanging, but I don't know if it will hang later, or it won't hang...

skyfly555
Posts: 8
Joined: Fri Nov 27, 2015 12:46 pm

Re: Trying to use a RPI 2 B as a router with 2 NICs - imposs

Mon Dec 14, 2015 11:59 am

It happened again, only 5 minutes working.

Tomorrow I'll use isc-dhcp and bind9 and see what happens.

User avatar
allfox
Posts: 452
Joined: Sat Jun 22, 2013 1:36 pm
Location: Guang Dong, China

Re: Trying to use a RPI 2 B as a router with 2 NICs - imposs

Mon Dec 14, 2015 1:00 pm

skyfly555 wrote:Tomorrow (I'll have time enough) I'll try to get your config working, I'll forget using dnsmasq and I'll use isc-dhcp-server as you say.
No, I didn't mean to change DHCP server. I mean change DHCP client. I'm with dnsmasq either, it's a very well software.

/etc/network/interfaces and /etc/dhcpcd.conf control DHCP client.

/etc/dnsmasq.conf controls DHCP server.

Mine "lsusb" command would output:

Code: Select all

allfox@pi1 ~ $ lsusb
Bus 001 Device 006: ID 1f75:0621 Innostor Technology Corporation
Bus 001 Device 005: ID 0b95:772b ASIX Electronics Corp. AX88772B
Bus 001 Device 004: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
allfox@pi1 ~ $
The second line is the USB adapter. You might check yours. The name may different but the USB ID should be the same: 0b95:772b.

skyfly555
Posts: 8
Joined: Fri Nov 27, 2015 12:46 pm

Re: Trying to use a RPI 2 B as a router with 2 NICs - imposs

Tue Dec 15, 2015 6:28 am

Allfox, thank you very much.

Finally, we've got the mistery solved.

Bus 001 Device 004: ID 0fe6:9700 Kontron (Industrial Computer Source / ICS Advent) DM9601 Fast Ethernet Adapter

I was sure it was simply an ASIX88772, but now looking at http://elinux.org/RPi_USB_Ethernet_adapters I see my trouble.

I have bought a TP-LINK UE300, in a few days I'll have it here.

Hugs, Allfox, and thaaaaaaaank you very much for taking your time to help me, I'm very grateful :)

skyfly555
Posts: 8
Joined: Fri Nov 27, 2015 12:46 pm

Re: Trying to use a RPI 2 B as a router with 2 NICs - imposs

Sun Dec 20, 2015 5:51 pm

Everything solved.

Thanks to allfox, I've bought a new, this time out-of-the-box compatible with RPi 2, Ethernet USB adapter (TPLINK UE300-USB 3.0-1Gb ethernet adapter). I've configured static IP address as allfox said, "the jessie way", setting /etc/network/interfaces manual, and IP static settings on dhcpcd.conf

Working great, totally stable, a joy using dnsmasq, it's very lightweight, and simple to configure,

Return to “General discussion”