Virtual NIC: "SIOCSIFFLAGS: Cannot assign requested address" but gets created
Solution 1
ifconfig
is considered obsolete these days. Try to use ip
tool instead. All recent distributions should support it, it's part of iproute
tool set.
If you just want additional IP address on the interface, use following command:
ip addr add 10.50.55.130/24 dev eth0
And I agree with Johan Myréen's comment bellow your question.
Solution 2
apart from command line method, the preferred method for Debian based system is to use networking configuration files.
The alias method prefers to use such order: eth0, eth:0:0, eth0:1,
...
So first alias to system would be eth0:0 and to achieve this persistent across system reboots, create a file /etc/network/interfaces.d/eth0
with such content:
auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
address 10.50.55.130/24
Or you can edit directly the file /etc/network/interfaces
but this is not recommended as it can be overwritten automatically.
The key is to use format of address with slash subnet, and not to use netmask
keyword anymore: address 10.50.55.130/24
And of course do
service networking restart
to test the configuration. Check afterwards with command:
service networking status
and
ip address
Please note, that like mentioned in comments, the actual name of the interface can be any, thus make sure to check interface names with ip addr
command and use that name and amend :0
and so on to that, like enp3s0f0:0 and enp3s0f0:1 and so on.
kisa_svnt
Updated on September 18, 2022Comments
-
kisa_svnt over 1 year
I am having some trouble with the apparently easy task of creating a virtual network adapter on a physical network card in my Linux system (custom distribution, Debian-based).
If I run
ifconfig eth0:1 10.50.55.130 netmask 255.255.255.0
everything goes just fine: the virtual NIC is silently added and correctly shown by
ifconfig
.I want the definition for this virtual NIC to appear in
/etc/network/interfaces
though. I have added the following stanza.# virtual NIC # auto eth0:1 iface eth0:1 inet static address 10.50.55.130 netmask 255.255.255.0
First line commented out because as of now I am not interested in having the system bring the network interface up automatically.
Everything seems fine.
If I run
ifup eth0:1
, though, I getSIOCSIFFLAGS: Cannot assign requested address
.What I really can't wrap my head around is that the virtual NIC is actually created. Here's the output from
ifconfig
.can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00- 00-00-00 UP RUNNING NOARP MTU:16 Metric:1 RX packets:1206446 errors:0 dropped:0 overruns:0 frame:0 TX packets:193280 errors:0 dropped:12 overruns:0 carrier:12 collisions:0 txqueuelen:10 RX bytes:7645126 (7.2 MiB) TX bytes:1393003 (1.3 MiB) Interrupt:68 can1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 UP RUNNING NOARP MTU:16 Metric:1 RX packets:299171 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10 RX bytes:2393368 (2.2 MiB) TX bytes:0 (0.0 B) Interrupt:71 eth0 Link encap:Ethernet HWaddr 98:5d:ad:c2:30:30 inet addr:10.90.100.43 Bcast:0.0.0.0 Mask:255.255.248.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1560275 errors:0 dropped:1 overruns:0 frame:0 TX packets:790 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:96964255 (92.4 MiB) TX bytes:176882 (172.7 KiB) Interrupt:56 eth0:1 Link encap:Ethernet HWaddr 98:5d:ad:c2:30:30 inet addr:10.50.55.130 Bcast:10.50.55.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:56 eth1 Link encap:Ethernet HWaddr 98:5d:ad:c2:30:32 inet addr:169.254.8.141 Bcast:169.254.255.255 Mask:255.255.0.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:140932 errors:0 dropped:0 overruns:0 frame:0 TX packets:140932 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:8522761 (8.1 MiB) TX bytes:8522761 (8.1 MiB)
Why am I getting this error? Or... Why does the NIC get created?
I'll add that if I invoke
ifup -f eth0:1
(with the force option) no error messages are shown AND the virtual network adapter is brought up just fine.-
Johan Myréen about 6 yearsInterface names like
eth0:1
do not denote separate interfaces, not even virtual ones. They are just aliases, i.e. different names for the real interface. Because they are just aliases, they don't have separate state – for example,eth0:1
can't be down ifeth0
is up. This alias mechanism is only needed because the oldifconfig
tool can only handle one address per device name.
-
-
Rui F Ribeiro about 6 yearsMore interestingly yet, in certain situations
ifconfig
does not show alias create withip
. +1 for theip
recommendation. -
Johan Myréen about 6 years@RuiFRibero Try adding
label eth0:1
to theip address add ...
line. -
Kojo about 3 yearsI made almost the same thing for several IPs, except that in order to restart successfully networking.service, I had to replace the legacy eth0 by my new interface name enp3s0f0, even if eth0 was the one in interfaces ... `auto enp3s0f0:1 iface enp3s0f0:1 inet static address aaa.bbb.ccc.ddd/30