Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
VLANs do not survive reboot [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
n3bul4
Apprentice
Apprentice


Joined: 04 Nov 2003
Posts: 184

PostPosted: Fri Feb 27, 2015 12:13 pm    Post subject: VLANs do not survive reboot [solved] Reply with quote

Hey guys,

I have one question.

I successfully managed to create a VLAN in the following way.
Code:

# vconfig add eth0 10
# ifconfig eth0.10 192.168.0.2 netmask 255.255.255.0
# route add default gw 192.168.0.1


My problem is that when I reboot the machine, the eth0.10 VLAN device is not created.

This is what I have in my /etc/conf.d/net file.

Code:

config_eth0="null"
vlans_eth0="10"
config_eth0_10="192.168.0.2 netmask 255.255.255.0"
routes_eth0_10="default via 192.168.0.1"


I also tried to set the module to "iproute2" but still the same problem.

Any help would be appreciated.


Regards


Last edited by n3bul4 on Sun Mar 01, 2015 11:09 am; edited 1 time in total
Back to top
View user's profile Send private message
n3bul4
Apprentice
Apprentice


Joined: 04 Nov 2003
Posts: 184

PostPosted: Sat Feb 28, 2015 8:19 pm    Post subject: Reply with quote

Nobody an idea?
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 13498

PostPosted: Sat Feb 28, 2015 8:30 pm    Post subject: Reply with quote

What output is printed at boot when the interface is supposed to come up?

Your manual configuration was done using vconfig, which is no longer supported by netifrc. Can you hand configure it using iproute2?
Back to top
View user's profile Send private message
n3bul4
Apprentice
Apprentice


Joined: 04 Nov 2003
Posts: 184

PostPosted: Sun Mar 01, 2015 11:08 am    Post subject: Reply with quote

Thanks for your hint!

I could actually solve it the following way:

Code:

#/etc/conf.d/net
config_eth0="null"

ip link add link eth0 name eth0.11 type vlan id 11
config_eth0_11="192.168.1.3 netmask 255.255.255.0"
routes_eth0_11="default via 192.168.1.1"


Followed by:

Code:

ln -s /etc/init.d/net.lo /etc/init.d/net.eth0.11
rc-update add net.eth0.11 default


The problem was, that at boot time it simply told me that the device eth0.11 was not not found.
I didn't know that I can use iproute2 commands directly in the /etc/conf.d/net file.

Regards
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1717

PostPosted: Sun Mar 01, 2015 12:32 pm    Post subject: Reply with quote

you do know that line
ip link add link eth0 name eth0.11 type vlan id 11
will be executed every time you call ANY of your net* scripts, don't you?

Netifrc uses modules translating it's internal comands to a form tools actually configuring network can understand. Vconfig is not supporte = there is no module for it. You can try iproute module instead as it's also capable of doing what you want.

Otherwise, at least encapsulate this line in an pre-up function declaration or something like that so it will only be called when you start the interface. And you might also need post-down to clean up afterwards. All that stuff a module normally handles for you.
Back to top
View user's profile Send private message
n3bul4
Apprentice
Apprentice


Joined: 04 Nov 2003
Posts: 184

PostPosted: Mon Mar 02, 2015 4:43 am    Post subject: Reply with quote

Hey szatox,

yeah I realized that the ip command is executed every time a network device is started / stopped.

It actually just gives me a warning, so I was not too much worried about that.
But you are totally right, that it is not a clean solution.

I actually tried a lot of different configurations including to define the iproute2 module like this:

Code:

modules="iproute2"


The problem was that it was always claiming about not finding the device (net.eth0.11 in this case).
So the device was not created by ip command.

It somehow seems, that iproute2 module doesn't recognize the configuration.

What I used was the following:

Code:

config_eth0="null"
vlans_eth0="11"
config_eth0_11="192.168.0.2 netmask 255.255.255.0"
routes_eth0_11="default via 192.168.0.1"


but it seems that iproute2 is ignoring the vlans_eth0 line and the ones that follow.
As I said it simply claims about not finding the device.

Anyway, thanks for your input. I wasn't aware about the pre-up / post-down functionality.

So for now I solved it the following way:

Code:

preup(){
        if [ ${IFACE} == "eth0.10" ]; then
                ip link add link eth0 name ${IFACE} type vlan id 10
        fi
}

postdown(){
        if [ ${IFACE} == "eth0.10" ]; then
                ip link del ${IFACE}
        fi
}


Which works perfectly and doesn't give me any warnings any more.

I am really wondering about how this can be achieved without those two functions.
Do you have an example configuration for using module iproute2 without the need of those functions?

Regards
Back to top
View user's profile Send private message
n3bul4
Apprentice
Apprentice


Joined: 04 Nov 2003
Posts: 184

PostPosted: Mon Mar 02, 2015 5:30 am    Post subject: Reply with quote

OK I actually figured it out on my own :)

This is a working /etc/conf.d/net

Code:

modules="iproute2"
config_eth0="null"

vlans_eth0="11"
config_eth0_11="192.168.0.2 netmask 255.255.255.0"
routes_eth0_11="default via 192.168.0.1"
vlan_11_name="vlan11"


My mistake was that I actually thought that I have to add a net.eth0.10 init script.

Code:

ln -s /etc/init.d/net.lo /etc/init.d/net.eth0.11
rc-update add net.eth0.11


This is actually not needed / wrong, so I simply removed the init script and now everything is working as expected without the need of any pre-up and post-down functions.
Code:

rc-update del net.eth0.11
rm /etc/init.d/net.eth0.11



Thanks for your help!

Regards
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum