1

I am working on setting up a VLAN network made up by 2 nodes. each consisting of multiple raspberry pis and a switch. For this purpose, I need to add a VLAN tag to the routing table of the raspberry pis. There is a lot of documentation about how to make changes to the routing table when adding a new entry, but only under the default labels such as gateway, interface, metric, flag, etc. What I wish to know is how to add a new label alongside the ones mentioned above. It would be great if anyone could help me with this.


@Ingo

Thank you for your answer. By routing table, I mean the table that we get after entering the following command:

route -n

Kernel IP routing table
Destination     Gateway   Genmask        Flags Metric Ref  Use   Iface
0.0.0.0         192.168.1.1  0.0.0.0       UG    202    0      0       eth0
192.168.1.0     0.0.0.0     255.255.255.0   U     202    0    0       eth0

I apologize for not making my question clear. I understand that gateway, interface, metric flag etc are properties but I wanted to know if I could add one more column for the VLAN ID.

Thanks in advance.

0

This isn't specific to Raspberry Pi. Anyway, I'm not sure if I understand what you mean. The items gateway, interface, metric, flag etc. are not simply labels on a table. They are properties of the routing mechanism. And what routing table do you mean? Mine has no labels:

rpi3 ~$  ip route
default via 192.168.10.2 dev vlan10 proto static
192.168.7.0/24 dev vlan7 proto kernel scope link src 192.168.7.1
192.168.10.0/24 dev vlan10 proto kernel scope link src 192.168.10.1
192.168.20.0/24 dev vlan20 proto kernel scope link src 192.168.20.1

For using VLAN you have to specify what VLANs your interface is connected to

rpi3 ~$ ip addr   # stripped to relevant info
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: ens5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:1c:38:55 brd ff:ff:ff:ff:ff:ff
3: vlan20@ens5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 52:54:00:1c:38:55 brd ff:ff:ff:ff:ff:ff
    inet 192.168.20.1/24 brd 192.168.20.255 scope global vlan20
4: vlan10@ens5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 52:54:00:1c:38:55 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.1/24 brd 192.168.10.255 scope global vlan10
    inet 192.168.10.10/24 brd 192.168.10.255 scope global secondary vlan10
5: vlan7@ens5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 52:54:00:1c:38:55 brd ff:ff:ff:ff:ff:ff
    inet 192.168.7.1/24 brd 192.168.7.255 scope global vlan7

and then you can route to the Virtual LANs like with normal interfaces. Look at my routing table. That's how routing to VLANs work.

For showing the routing table with old style route it isn't possible to add a column labeled "VLAN" but it isn't needed. The vlanX is shown in column "Iface". VLANs have normal (virtual) interfaces:

rpi3 ~$ sudo route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.10.2    0.0.0.0         UG    0      0        0 vlan10
192.168.7.0     0.0.0.0         255.255.255.0   U     0      0        0 vlan7
192.168.10.0    0.0.0.0         255.255.255.0   U     0      0        0 vlan10
192.168.20.0    0.0.0.0         255.255.255.0   U     0      0        0 vlan20
  • Since I couldn't add the routing table in the comment in the proper format, I had to post the comment as an answer. I would really appreciate any input you can provide. – Doe.John Apr 13 '18 at 1:45
  • @Doe.John Editing the question is the right way. I have updated my answer for old style route. – Ingo Apr 13 '18 at 7:30
  • Thank you for sharing your answer. Also, I'm fairly new here and this was my first question, so I'll keep that in mind. – Doe.John Apr 13 '18 at 15:02
  • Does the answer meets your question? So you can accept it to finalize it. And yes, to take the tour is also a good thing ;-) – Ingo Apr 13 '18 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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