Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Networking & Security
  • Search

[SOLVED] multiple IP aliases per ethernet interface

Having problems getting connected to the internet or running a server? Wondering about securing your box? Ask here.
Post Reply
Advanced search
7 posts • Page 1 of 1
Author
Message
yolabingo
n00b
n00b
User avatar
Posts: 12
Joined: Thu Feb 19, 2009 8:29 pm
Location: New Mexico
Contact:
Contact yolabingo
Website

[SOLVED] multiple IP aliases per ethernet interface

  • Quote

Post by yolabingo » Mon Mar 28, 2016 8:01 pm

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: Select all

# 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: Select all

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: Select all

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: Select all

# /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.
Top
Hu
Administrator
Administrator
Posts: 24395
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Tue Mar 29, 2016 1:18 am

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?
Top
yolabingo
n00b
n00b
User avatar
Posts: 12
Joined: Thu Feb 19, 2009 8:29 pm
Location: New Mexico
Contact:
Contact yolabingo
Website

  • Quote

Post by yolabingo » Tue Mar 29, 2016 2:23 am

You are correct. I was relying on the output of ifconfig to show ethernet aliases, which it apparently no longer does.

Code: Select all

ip addr
does show both interfaces, and they behave as expected.

Thank you.
Top
khayyam
Watchman
Watchman
User avatar
Posts: 6227
Joined: Thu Jun 07, 2012 2:45 am
Location: Room 101

Re: multiple IP aliases per ethernet interface not working

  • Quote

Post by khayyam » Tue Mar 29, 2016 2:27 am

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
Top
yolabingo
n00b
n00b
User avatar
Posts: 12
Joined: Thu Feb 19, 2009 8:29 pm
Location: New Mexico
Contact:
Contact yolabingo
Website

  • Quote

Post by yolabingo » Tue Mar 29, 2016 3:14 am

@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.
Top
marcelser
Tux's lil' helper
Tux's lil' helper
Posts: 106
Joined: Thu Sep 30, 2004 9:53 pm

follow-up

  • Quote

Post by marcelser » Thu Mar 02, 2023 1:02 pm

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: Select all

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
Top
grknight
Retired Dev
Retired Dev
Posts: 2564
Joined: Fri Feb 20, 2015 9:36 pm

Re: follow-up

  • Quote

Post by grknight » Thu Mar 02, 2023 1:47 pm

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:
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: Select all

interfaces = 192.168.10.37/24
Top
Post Reply

7 posts • Page 1 of 1

Return to “Networking & Security”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic