Adding IP to NIC whose main IP is on different subnet/gateway?

How to add an additional IP to a NIC with main IP on different subnet/gateway?

A server running FreeBSD 11-RELEASE has main IP:

Code:
IP: 144.76.60.19
Gateway: 144.76.60.1
Netmask: 255.255.255.224

The server has already been assigned an additional IP, on same gateway as main IP:

Code:
IP: 144.76.60.26
Gateway: 144.76.60.1
Netmask: 255.255.255.224

which was successfully added with following line, in rc.conf:

Code:
ifconfig_em0_alias0="inet 144.76.60.26  netmask 255.255.255.224"

After requiring another new IP, the server has been assigned an IP on a different subnet/gateway:

Code:
IP: 148.251.242.246
Gateway: 148.251.242.241
Netmask: 255.255.255.248

I tried to add the new IP in rc.conf, like this:

Code:
ifconfig_em0="DHCP"

# First additional IP
ifconfig_em0_alias0="inet 144.76.60.26  netmask 255.255.255.224"

# Additional IP, different gateway
ifconfig_em0_alias1="inet 148.251.242.246 netmask 255.255.255.248"

# Add internal IPs for jails
cloned_interfaces="lo1"
ipv4_addrs_lo1="10.0.0.1-10/29"

Although, with above configuration, that additional IP is reachable from outside:

http://148.251.242.246

after restarting netif, I get this error:

Code:
root@scs:~ # service netif restart
/etc/rc.conf: interfaces: not found
/etc/rc.conf: interfaces: not found
/etc/rc.conf: interfaces: not found
Stopping dhclient.
Waiting for PIDS: 573.
Stopping Network: lo0 em0 lo1 pflog0.
lo0: flags=8048<LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
    groups: lo
em0: flags=8c02<BROADCAST,OACTIVE,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=4219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MAGIC,VLAN_HWTSO>
    ether 60:a4:4c:22:a5:73
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
lo1: flags=8048<LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
    groups: lo
pflog0: flags=100<PROMISC> metric 0 mtu 33160
    groups: pflog
Destroyed clone interfaces: lo1.
Created clone interfaces: lo1.
Starting Network: lo0 em0 lo1.
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
    inet6 ::1 prefixlen 128
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
    inet 127.0.0.1 netmask 0xff000000
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
    groups: lo
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=4219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MAGIC,VLAN_HWTSO>
    ether 60:a4:4c:22:a5:73
    inet 144.76.60.26 netmask 0xffffffe0 broadcast 144.76.60.31
    inet 148.251.242.246 netmask 0xfffffff8 broadcast 148.251.242.247
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
    media: Ethernet autoselect
    status: no carrier
lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
    inet 10.0.0.1 netmask 0xfffffff8
    inet 10.0.0.2 netmask 0xffffffff
    inet 10.0.0.3 netmask 0xffffffff
    inet 10.0.0.4 netmask 0xffffffff
    inet 10.0.0.5 netmask 0xffffffff
    inet 10.0.0.6 netmask 0xffffffff
    inet 10.0.0.7 netmask 0xffffffff
    inet 10.0.0.8 netmask 0xffffffff
    inet 10.0.0.9 netmask 0xffffffff
    inet 10.0.0.10 netmask 0xffffffff
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
    groups: lo
/etc/rc.conf: interfaces: not found

Could somebody please tell me, or give a link on how to add an additional IP to a NIC with main IP on different subnet/gateway?
 
Back
Top