0

I think I might be missing something simple, but I'm at the point of needing some extra eyes on the problem. I have a need for 2 separate networks to be on the same NIC (eth1): 192.168.0.0/24 and 192.168.1.0/24. The interfaces are:

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 192.168.1.250  netmask 255.255.255.0  broadcast 192.168.1.255
    ether 0c:c4:7a:7d:bb:f8  txqueuelen 1000  (Ethernet)
    RX packets 24515  bytes 5405247 (5.1 MiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 31116  bytes 3036051 (2.8 MiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    device interrupt 16  memory 0xdf200000-df220000  

eth1:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 192.168.0.250  netmask 255.255.255.0  broadcast 192.168.0.255
    ether 0c:c4:7a:7d:bb:f8  txqueuelen 1000  (Ethernet)
    device interrupt 16  memory 0xdf200000-df220000  

In /etc/sysconfig/dhcpd I have

DHCPD_INTERFACE="eth1 eth1:1"
DHCPDARGS="eth1 eth1:1"

In /etc/dhcpd.conf I have

subnet 192.168.0.0 netmask 255.255.255.0 {
    pool {
       ....
    }
}
subnet 192.168.1.0 netmask 255.255.255.0 {
    pool {
        ....
    }
}

Yet, when I start dhcpd, I see this

$ sudo journalctl -xeu dhcpd.service
  ....
dhcpd[5113]: No subnet declaration for eth1:1 (no IPv4 addresses).
dhcpd[5113]: ** Ignoring requests on eth1:1.  If this is not what
dhcpd[5113]:    you want, please write a subnet declaration
dhcpd[5113]:    in your dhcpd.conf file for the network segment
dhcpd[5113]:    to which interface eth1:1 is attached. **
  ....

Why?

4
  • 1
    Instead of using "virtual interfaces", have you tried simply assigning both addreses to eth1? That works perfectly fine on my system. Commented Jan 11, 2018 at 18:25
  • @grawity yes I did try that as well. ifconfig did not show both addresses but I could ping them (curious). I was using these: ostechnix.com/…. However, I did run into similar issues with dhcpd though not the one listed above. Specifically, dhcpd would not vend addresses on the second network assigned. Commented Jan 11, 2018 at 18:32
  • 2
    That's only because ifconfig has been written for obsolete APIs and has no understanding of multiple IP addresses per interface – even though Linux in general and modern tools (such as ip addr) have supported that for many years. Do not use ifconfig on Linux. Commented Jan 11, 2018 at 18:34
  • Also, are those subnet declarations inside a shared-network declaration for eth1? Commented Jan 12, 2018 at 5:57

1 Answer 1

0

Network interface names like eth1:1 do not designate separate interfaces, not even virtual ones. eth1:1 is just an alias for the eth1 interface that exists because ifconfig is dumb (and should not be used, as noted in the comments above.)

You should use a shared-network declaration for eth1 including the two subnet declarations. An IP address for both subnets should also be assigned to eth1. Btw, you can add a label to the address to achieve compatibility with ifconfig, e.g.

 ip addr add 192.168.1.250/24 label eth1:1 dev eth1

There is still one problem: the clients' requests come in on a single wire, each request containing the client's MAC address and 0.0.0.0 as the source IP address. If a dynamic IP address is to be handed out, the DHCP server has no clue from which subnet it should assign an IP address to the client. The shared-network setting is intended for the case where two or more subnets are combined in a pool of addresses, and is really not suitable for subnets having different roles.

1
  • This answer is quite consistent with my findings. Commented Jan 16, 2018 at 0:46

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.