How to Use a Junos Switch as a Router
Juniper EX series switches support many of the standard Junos OS routing protocols, including static routing, RIP, OSPF, IS-IS, and BGP, as well as features such as VRRP. To enable inter-VLAN communication, you configure a Layer 3 (routing) logical interface on the switch for each VLAN. The switch treats these just like any other interface, so you can route traffic to and from VLANs through these interfaces.
The switch maintains routing tables to compile information learned from the routing protocols and from other routing information sources. The switch creates the same routing tables (and forwarding tables) and uses them in the same way as JUNOS routers do.
Connect to the Internet
If you have a small LAN with a single connection to the Internet, you can easily connect to your service provider’s edge router by configuring a static route from the switch to the router. The static route configuration is straightforward, and the route remains in the switch’s routing table until you remove it, or until it becomes inactive for some reason.
You need just a few commands to configure the static route. First, set the IP address on the switch interface that connects to the service provider:
[edit interfaces] user@junos-switch# set ge-0/0/10 unit 0 family inet address 192.168.0.2/30
As you can see in this example, you can configure any interface on an EX series switch to be a Layer 3 routed interface instead of a switch interface. You configure the interface to be a Layer 3 interface by configuring a Layer 3 family statement on the interface.
Of course, if you do so, you can’t also configure the family ethernet-switching statement on the same interface. That configuration would be very confusing — like telling your convertible car to have its top down and up at the same time — so the Junos OS software won’t let you do that.
Then create a default route (a route with the address 0.0.0.0) to that switch interface:
[edit routing-options] user@junos-switch# set static route 0.0.0.0/0 next-hop 192.168.0.1
Connect to a router in your LAN
In larger networks, switches can perform different functions. Everything described here is for access switches, which are the switches that connect end-user network devices, such as computers and printers, to the LAN. But large LANs can have dozens of switches that need to connect to the LAN core or to WAN edge layer switches.
The switches at the LAN core or WAN edge are called aggregation, or distribution, switches. (In some cases, the network is large enough that the distribution switches need to be connected together at another layer of aggregation. In those cases, you might use core switches to aggregate the distribution switches together.)
You may need to configure a distribution switch if, for example, you move traffic between a number of different switches within your organization. The switches can be in the same building, or they may be geographically dispersed across a campus, city, country, or even around the world. The switches can communicate using the bridging, spanning tree, and other mechanisms.
Or you may need to move traffic between your network and the Internet. In this case, your distribution switches link to routers that in turn connect to the Internet. The switch interfaces that connect to the routers usually communicate either with a single Layer 3 interface or with a single Layer 2 interface with VLAN trunking enabled.
If you choose to use a Layer 3 interface, you need to get routing information on the switches by either configuring static routes or using a dynamic routing protocol (such as OSPF or IS-IS). If you choose to configure routing protocols on the switch, you do so in the same way as you do on any Junos OS software router.