Hi!
Some time ago I configured my Raspberry Pi as a home router. Below, in short brief is shown my configuration.
On the Cisco switch, I have created two vlans:
vlan10 – WAN (Internet connection)
vlan20 – LAN (Home network)
The first port of the Cisco switch is connected to the the Internet, and is configured as access port for vlan10. The second port is connected to the Raspberry Pi as trunk port – traffic from vlan10 and vlan20 is tagged on this port. Third port is in access mode and is connected to the home access point.
1 2 3 4 5 6 7 8 9 10 11 |
interface FastEthernet0/3 switchport access vlan 20 ! interface FastEthernet0/2 switchport mode trunk ! interface FastEthernet0/1 switchport access vlan 10 ! interface Vlan20 ip address 192.168.50.2 255.255.255.0 |
1 2 3 4 5 6 7 |
Switch#show vlan brief VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/4 10 INTERNET active Fa0/1 20 LAN active Fa0/3 |
Network configuration on Raspberry Pi looks as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
root@raspberrypi:/home/pi# cat /etc/network/interfaces auto lo iface lo inet loopback # Management iface eth0 inet static address 192.168.100.1 netmask 255.255.255.0 post-up ifup vlan10 post-up ifup vlan20 # Internet auto vlan10 iface vlan10 inet dhcp hwaddress ether 00:12:2a:a7:f7:c0 vlan-raw-device eth0 # Home network auto vlan20 iface vlan20 inet static address 192.168.50.1 netmask 255.255.255.0 vlan-raw-device eth0 |
On eth0 interface I have set 192.168.100.1 address for management purpose in case of problems with access to the Raspberry Pi from vlan’s side. On vlan10 interface I have to set the custom mac address to obtain IP address from my internet provider. Vlan20 with addresses 192.168.50.1/24 is for my home network.
The rest of my configuration like NAT, dhcp, dns is pretty standard and will not be posted about it here. If you have questions, I will be happy to answer in the comments 🙂
How Raspberry Pi performs as a router on my 100/50 Mb/s internet connection? Quite nicely for a network card supported by USB – which has Raspberry.