Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I know that a router is necessary for VLANs to communicate with each othe, but I would like to know if both IP address and default gateway need to be configured on the switch in order for different vlans connected to them communicate with each other?

Thank you in advance.

share|improve this question
    
It's not clear what you mean. What are you expecting the switch to do? (Your question is like asking if a belt has to be buckled to shoot a burglar. If you're expecting the belt to shoot the burglar, buckled or not, it cannot do it. If you're expecting a cop to shoot the burglar, it matters not whether his belt is buckled.) –  David Schwartz May 29 '12 at 9:29
    
@davidSchwartz sorry for the confusion, here is the original question on stackoverflow: stackoverflow.com/questions/10796032/… –  xczzhh May 29 '12 at 9:33
1  
In that diagram, the VLANs will be able to communicate with each other if there's some device that enables them to. The switch will not do this, but it will switch the VLANs so that traffic flows to and from some other device (such as a router) that moves traffic from one VLAN to another (assuming such a device exists and is properly configured). –  David Schwartz May 29 '12 at 9:36
add comment

2 Answers

The switch will switch, no matter what. If that allows the VLANs to communicate with each other because the proper routing is in place, then it makes no difference whether the switch has an IP address or default gateway. All it's going to do is switch, and it can do that without a default gateway or IP address.

Something has to route between the VLANs, and the switch won't do that. But the switch will happily switch packets to and from the device that's doing the inter-VLAN routing.

Say you want to get traffic from VLAN 7 to VLAN 8. A switch will happily carry the VLAN 7 traffic to a router, which will route it onto VLAN 8. Then the switch will happily carry the VLAN 8 traffic from the router. So the switch will do its part of switching inside each VLAN to allow the router to do its job of interconnecting the VLANs.

share|improve this answer
    
Thank you for the answer, Sir. Very clear, there is no need to configure an IP address and default gateway on a switch doing work like this. –  xczzhh May 29 '12 at 9:38
1  
A pure switch will only have an IP address and default gateway to manage the switch. It plays no role in its switching behavior. –  David Schwartz May 29 '12 at 9:40
    
Got it, thank you again ;) @davidschwartz –  xczzhh May 29 '12 at 9:41
add comment

You can easily find nowadays Layer 3 switches, i.e., switches with routing capabilities. It works by creating virtual interfaces (vlan interfaces) with IP addresses. Just doing that you create entries on the switch routing table (yes, as I've said, it behaves as a router!) and the vlans will communicate with each other.

You can add static routes (as a default route pointing to your firewall, for example) or even enable a dynamic routing protocol (ospf, bgp...), depending on the hardware and firmware available resources. And your hosts and servers can use this switch as their default route.

Here is an example on a Cisco switch:

!
interface Vlan5
 ip address 10.50.0.1 255.255.255.0
!
interface Vlan6
 ip address 10.60.0.1 255.255.255.0
!
interface GigabitEthernet0/1
 description Desktop station
 switchport
 switchport access vlan 5
 switchport mode access
!
interface GigabitEthernet0/2
 description Server
 switchport
 switchport access vlan 6
 switchport mode access
!
ip route 0.0.0.0 0.0.0.0 10.60.0.254
!
switch1#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is 10.60.0.254 to network 0.0.0.0

     10.0.0.0/8 is variably subnetted, 2 subnets, 1 mask
C       10.50.0.0/24 is directly connected, Vlan5
C       10.60.0.0/24 is directly connected, Vlan6

In this example, the device connected on interface G0/1 will be able to communicate with the other one connected on the G0/2, even though they are on different vlans (and that default route is not required).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.