View previous topic :: View next topic |
Author |
Message |
tylerd75 n00b
Joined: 29 Aug 2005 Posts: 52 Location: Norway
|
Posted: Sat Feb 11, 2006 11:16 pm Post subject: How do I setup a permanent virtual ethernet iface? |
|
|
I'm trying to setup a virtual interface to expand my LAN to cover 2 subnets.
The actual setup is easy (with ipconfig eth0:0 <IP> netmask <netmask>... and the route is correct.
But how do I create something like that in /etc/conf.d/net?
If I create a virtual interface in net I get the error: eth00 does not exist (I couldn't use ":" in the iface name, so I called it eth00 instead...)
Any ideas?
Cheers,
TylerD |
|
Back to top |
|
|
nms n00b
Joined: 16 Jul 2005 Posts: 43 Location: Umeå, Sweden
|
Posted: Sun Feb 12, 2006 1:08 am Post subject: |
|
|
This is how my IPv6 interface is set up on my server, but I haven't touched the configuration in a few months so I'm not quite sure if I remember it all correctly. The concept should be somewhat in the right direction, though. General waiver of liability applies.
Install iproute2:
Instruct the rc scripts to use iproute2 in /etc/conf.d/net:
Code: | modules=( "iproute2" ) |
Add your interface to /etc/conf.d/net:
Code: | config_mynewinterface=( "172.16.43.4/24" )
routes_mynewinterface=( "172.16.0.0/16 via 172.16.43.1" ) |
(The routes_ line is only required if you need to route the traffic to the secondary network through another gateway than your default.)
Create an rc script to start your new interface:
Code: | cd /etc/init.d/
ln -s net.lo net.mynewinterface |
Now all you should have to do is run the script:
Code: | /etc/init.d/net.mynewinterface start |
And if that works and you want the interface to start at boot:
Code: | rc-update add net.mynewinterface default |
|
|
Back to top |
|
|
CriminalMastermind Tux's lil' helper
Joined: 19 Nov 2003 Posts: 132 Location: toronto
|
Posted: Sun Feb 12, 2006 8:12 am Post subject: |
|
|
tylerd75 wrote: | I'm trying to setup a virtual interface |
i believe what you are looking for is often called an alias. hope this helps you out. _________________ "I can picture a perfect world that knows of no war... and I can picture me attacking that world, because they'd never expect it." |
|
Back to top |
|
|
nms n00b
Joined: 16 Jul 2005 Posts: 43 Location: Umeå, Sweden
|
Posted: Sun Feb 12, 2006 12:56 pm Post subject: |
|
|
After a few hours of sleep I realised that my example above is totally useless since I'm using tunneling for my extra interfaces. This is the way to do it for aliases:
Code: | config_eth0=(
"192.168.0.4/24"
"10.3.25.6/16"
)
routes_eth0=(
"default via 192.168.0.1"
"10.0.0.0/8 via 10.3.0.1"
) |
All according to http://www.gentoo.org/doc/en/handbook/2005.1/handbook-x86.xml?part=4&chap=2. |
|
Back to top |
|
|
tylerd75 n00b
Joined: 29 Aug 2005 Posts: 52 Location: Norway
|
Posted: Sun Feb 12, 2006 6:55 pm Post subject: |
|
|
Thanks nms and CriminalMastermind!
This solved my problem, and gave me some insight into how flexible the /etc/conf.d/net file can be (just like the rest of Gentoo!)!
Cheers!
TylerD |
|
Back to top |
|
|
faemin n00b
Joined: 16 Oct 2012 Posts: 22
|
Posted: Tue Oct 16, 2012 6:45 am Post subject: BUMP: virtual interfaces after reboot |
|
|
...
Last edited by faemin on Sun Dec 02, 2012 9:47 pm; edited 1 time in total |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Tue Oct 16, 2012 2:19 pm Post subject: Re: BUMP: virtual interfaces after reboot |
|
|
faemin wrote: | The solution above kind of works for me, but I am not happy with the Gentoo solution, as the virtual interfaces are not named like eth0:0, eth0:1, etc. |
faemin ... by default openrc will use iproute2 to configure network interfaces, and iproute2 doesn't create virtual interfaces in the same way as ifconfig, they are not 'labeled', and as ifconfig expects them to be labeled it doesn't show them in its output.
faemin wrote: | I use one of the two methods to declare the addresses, but it gives me a different result then if I do
Code: | ifconfig eth0:0 192.168.0.5 up |
This creates an address that shows up as eth0:0 with ifconfig. |
... and the following should do the same (using iproute2)
Code: | # ip addr add local 192.168.0.1/32 dev eth0 label eth0:1
# ip addr add local 192.168.0.2/32 dev eth0 label eth0:2 |
If you want to use 'ifconfig' to configure your interfaces then you should set 'modules=' so that ifconfig is used in perference to iproute2:
/etc/conf.d/net
Code: | modules_eth0="ifconfig"
config_eth0="192.168.0.1/24 192.168.0.2/24" |
best ... khay |
|
Back to top |
|
|
faemin n00b
Joined: 16 Oct 2012 Posts: 22
|
Posted: Tue Oct 16, 2012 10:15 pm Post subject: |
|
|
...
Last edited by faemin on Sun Dec 02, 2012 9:46 pm; edited 1 time in total |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sat Oct 20, 2012 3:14 pm Post subject: |
|
|
faemin wrote: | OK thanks, I will try that. |
faemin ... actually I should have stated the modules preference this way:
Code: | modules_eth0="!iproute2" |
Note that you might also want to read the section on "VLAN (802.1q support)" in /usr/share/doc/openrc-{version}/net.example.bz2 and also the examples provided for "pass[ing] parameters to go with an address", that is, if you were wondering how iproute2 would be similarly configured.
faemin wrote: | Also, the second part of my question. I want the Tor Relay running on one IP Address, and all traffic to/from to show that IP, including source address. I want the same for the email server, for another ip address. |
... and so you would set these services to 'listen' on the address provided for the respective virtual interfaces.
faemin wrote: | Finally, I am a n00b, should this have bee a separate topic? |
probably, yes :)
best ... khay |
|
Back to top |
|
|
faemin n00b
Joined: 16 Oct 2012 Posts: 22
|
Posted: Sun Oct 21, 2012 1:47 am Post subject: |
|
|
...
Last edited by faemin on Sun Dec 02, 2012 9:45 pm; edited 1 time in total |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sun Oct 21, 2012 10:21 am Post subject: |
|
|
faemin wrote: | khayyam wrote: | ... and so you would set these services to 'listen' on the address provided for the respective virtual interfaces. |
OK, when I do that, it is still routing traffic for the gateway associated with the primary address on the primary interface. I put tor to "listen" on for ex. 192.168.0.2, and mail smtp on 192.168.0.1, but everything seems to show the source address for whatever address is listed first in the array list of conig_eth0="..." |
faemin ... in which case don't assign an address to 'eth0'
Again, see the section "VLAN (802.1q support)" in /usr/share/doc/openrc-{version}/net.example.bz2.
best ... khay |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sun Oct 21, 2012 10:23 am Post subject: |
|
|
dupe ... can't delete and so, ignore |
|
Back to top |
|
|
|