how to set gateway for VLAN in if-cfg file?

Latest response

I'm trying to use https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s1-networkscripts-interfaces.html to configure VLAN over LACP teaming.

I've created ifcfg-team0.200 file, with such content:

DEVICE=team0.200
BOOTPROTO=none
ONBOOT=yes
IPADDR=***
NETMASK=255.255.255.0
VLAN=yes
DNS=***
PEERDNS=yes

But there are no GATEWAY parameter,
So, to make it work, I've also modified /etc/sysconfig/network file and included GATEWAY=... there.

But I have several VLANs and each of them has own GATEWAY.
How can I set GATEWAY to VLAN, not globally?

Responses

GATEWAY is the default gateway, so where all traffic should go that has not been defined by a static route.
Static routes are defined in /etc/sysconfig/network-scripts/route-team0.200 amd other /etc/sysconfig/network-scripts/route-devicename files.

GATEWAY is an ENVIRONMENT VARIABLE, so defining it multiple times may cause confusion and unpredictable values. For it might be that after a reboot or service network restart NICs are started in a different order.

Kind regards,

Jan Gerrit Kootstra

To add to Jan Gerrit Kootstra's response - the documentation can be found here:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s1-networkscripts-static-routes.html

There are additional considerations for multi-homed hosts with several routeable addresses. I, however, am not versed enough to be able to give a short summary of things to look for. Perhaps if you provide a short explanation of number of interfaces, where they will be routed to, we could assist further (if needed).

Thanks, it seems I was confused with Windows UI which allows me to set "gateway per VLAN". I've found that just using default gateway works for me.

Hello Oleg

The section James Radtke linked to has been improved again to show use the use of "ip route" to display the routing table. It is always worth checking the routing table before, and after, making any changes (with a "network service restart" after making a change).

The update will be published tomorrow.

As Jan pointed out, static routes can stored per-interface (but not globally in Red Hat Enterprise Linux).