View previous topic :: View next topic |
Author |
Message |
yolabingo n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/gallery/Simpsons/simpsons_krusty.gif)
Joined: 19 Feb 2009 Posts: 12 Location: New Mexico
|
Posted: Mon Mar 28, 2016 8:01 pm Post subject: [SOLVED] multiple IP aliases per ethernet interface |
|
|
I am trying to set up multiple IP addresses (aliases) on a single ethernet interface, so I'll have, for example,
enp4s0f1: 192.168.100.1/24
enp4s0f1:0: 192.168.100.33/24
Hardware is Ethernet controller: Intel Corporation 80003ES2LAN Gigabit Ethernet Controller (Copper) (rev 01)
Kernel driver in use: e1000e
net.example says:
Code: | # If you need more than one address, you can use something like this
# NOTE: ifconfig creates an aliased device for each extra IPv4 address
# (eth0:1, eth0:2, etc)
# iproute2 does not do this as there is no need to
# WARNING: You cannot mix multiple addresses on a line with other parameters!
#config_eth0="192.168.0.2/24 192.168.0.3/24 192.168.0.4/24"
# However, that only works with CIDR addresses, so you can't use netmask. |
I have this line in /etc/conf.d/net
Code: | config_enp4s0f1="192.168.100.1/24 192.168.100.33/24"
|
but when I start /etc/init.d/net.enp4s0f1, ifconfig shows just a single interface comes up
Code: | enp4s0f1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.100.1 netmask 255.255.255.0 broadcast 192.168.100.255 |
It _looks_ like it is trying to do the right thing:
Code: | # /etc/init.d/net.enp4s0f1 -v start
* Bringing up interface enp4s0f1
* Skipping module adsl due to missing program: /usr/sbin/adsl-start /usr/sbin/pppoe-start
* Skipping module br2684ctl due to missing program: br2684ctl
* Skipping module bridge due to missing program: brctl
* Skipping module clip due to missing program: /usr/sbin/atmsigd
* Skipping module ethtool due to missing program: ethtool
* Skipping module netplugd due to missing program: /sbin/netplugd
* Skipping module ifplugd due to missing program: /usr/sbin/ifplugd
* Skipping module ipppd due to missing program: /usr/sbin/ipppd
* Skipping module iwconfig due to missing program: /sbin/iwconfig
* Skipping module firewalld due to missing program: firewall-cmd
* Skipping module pppd due to missing program: /usr/sbin/pppd
* Skipping module dhclient due to missing program: /sbin/dhclient
* Skipping module pump due to missing program: /sbin/pump
* Skipping module dhcpcd due to missing program: dhcpcd
* Loaded modules: apipa arping bonding tuntap ccwgroup macvlan macchanger macnet wpa_supplicant ssidnet iproute2 system vlan udhcpc ip6rd ip6to4
* Configuring enp4s0f1 for MAC address 00:30:48:8E:7F:2F ... [ ok ]
* 192.168.100.1/24 ...
* ip addr add 192.168.100.1/24 broadcast + dev enp4s0f1 [ ok ]
* 192.168.100.33/24 ...
* ip addr add 192.168.100.33/24 broadcast + dev enp4s0f1 [ ok ] |
Thanks in advance
Last edited by yolabingo on Tue Mar 29, 2016 3:15 am; edited 1 time in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23093
|
Posted: Tue Mar 29, 2016 1:18 am Post subject: |
|
|
That output seems to show that it added both addresses. What is the output of ip addr? What symptoms make you think that it failed? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
yolabingo n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/gallery/Simpsons/simpsons_krusty.gif)
Joined: 19 Feb 2009 Posts: 12 Location: New Mexico
|
Posted: Tue Mar 29, 2016 2:23 am Post subject: |
|
|
You are correct. I was relying on the output of ifconfig to show ethernet aliases, which it apparently no longer does.
does show both interfaces, and they behave as expected.
Thank you. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
khayyam Watchman
![Watchman Watchman](/images/ranks/rank-G-2-watchman.gif)
![](images/avatars/9397496074fd0189143bb7.png)
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Tue Mar 29, 2016 2:27 am Post subject: Re: multiple IP aliases per ethernet interface not working |
|
|
yolabingo wrote: | [...] so I'll have, for example,
enp4s0f1: 192.168.100.1/24
enp4s0f1:0: 192.168.100.33/24 |
yolabingo ... that is ifconfig/net-tools notation, as 'net.example' states "iproute2 does not do this as there is no need to". You could however add a 'label' (ie, 'label enp4s0f1:0' ... see the section on "pass[ing] parameters" in net.example) but there isn't any need to, unless you absolutely must use the obsolete 'ifconfig' for viewing interface names, and if that were the case you could set modules="!iproute2" and have netifrc use ifconfig for creating the virtuals.
HTH & best ... khay |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
yolabingo n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/gallery/Simpsons/simpsons_krusty.gif)
Joined: 19 Feb 2009 Posts: 12 Location: New Mexico
|
Posted: Tue Mar 29, 2016 3:14 am Post subject: |
|
|
@khayyam - yes that definitely helps.
I must confess that while net.example is a great resource, I have not fully digested all 1200 lines of it.
Thanks all - the Gentoo community has always been remarkably helpful and patient. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
marcelser Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
Joined: 30 Sep 2004 Posts: 102
|
Posted: Thu Mar 02, 2023 1:02 pm Post subject: follow-up |
|
|
I know this thread is very old, but maybe somebody is interested in the solution below because sometimes you still need an alias even when using iproute2.
I actually also needed a second ip address for having "unbound" on one ip and "samba4" listening on the other. Problem is because iproute2 does not add those aliases in ifconfig and you cannot specify an ip address for samba but just the interface "enp0s25" samba4 tries to bind on both ip addresses for this interface (makes sense somehow).
Furthermore switching to ifconfig was also not an option because I also have macvlans for docker etc. which are not supported if you switch to ifconfig module. The solution the actually really mimic the old behaviour and have an alias with iproute2 is as follows (as mentioned before by kayyan) by adding a label:
Code: | config_enp0s25="192.168.10.36/24
192.168.10.37/24 label enp0s25:0"
|
BTW: the newline IS important a s you cannot pass custom options in one line.
This way it creates a enp0s25:0 interface with the other ip address and then samba4 also takes up just one ip and leaves the aliased one alone. Just in case you come accross other software that determines the ip address by interface and you don't want to provide both ips |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
grknight Retired Dev
![Retired Dev Retired Dev](/images/ranks/rank-retired.gif)
Joined: 20 Feb 2015 Posts: 2005
|
Posted: Thu Mar 02, 2023 1:47 pm Post subject: Re: follow-up |
|
|
marcelser wrote: | you cannot specify an ip address for samba but just the interface "enp0s25" samba4 tries to bind on both ip addresses for this interface (makes sense somehow). |
According to the documentation, this is not true:
Quote: | The (interfaces) option takes a list of interface strings. Each string can be in any of the following forms:
- a network interface name (such as eth0). This may include shell-like wildcards so eth* will match any interface starting with the substring "eth"
- an IP address. In this case the netmask is determined from the list of interfaces obtained from the kernel
- an IP/mask pair.
- a broadcast/mask pair
|
It can just be (from your example):
Code: | interfaces = 192.168.10.37/24 |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|