F-Stack / f-stack

F-Stack is an user space network development kit with high performance based on DPDK, FreeBSD TCP/IP stack and coroutine API.
http://www.f-stack.org
Other
3.87k stars 899 forks source link

How to use multiple IP addresses for 1 NIC? #771

Open markman76 opened 1 year ago

markman76 commented 1 year ago

I want to assign 2 IP addresses to 1 NIC, but only the first IP address is OK, the other is NG. For example, 1 NIC is mapped DPDK and the Port config is the below.

config.ini (for socket client modified from F-Stack example)

[port0] addr=172.16.1.1 netmask=255.255.0.0 broadcast=172.16.1.255 gateway=172.16.11.1

[port1] addr=172.16.2.1 netmask=255.255.255.255 broadcast=172.16.1.255 gateway=172.16.11.1

"172.16.1.1" can be connected to socket server (172.16.11.1). But "172.16.2.1" can't be connected to it.

How to use 2 or more IP addresses for 1 NIC?

jfb8856606 commented 1 year ago

You need config multi ips to [port0] with tool ff_ifconfig(all F-Stack versions) or vip_addr argument in config.ini(versions after F-Stack v1.22), but not [port1].

Note: If you use F-Stack as a client, FreeBSD stack only can use the default IP, can't use others IP by default, you can select custom source ip via pcb lddr api