1

I want to create a virtual interface for enp1s0, so that i can have multiple IP Address. I ran the below commands:

# ifconfig enp1s0 192.168.0.2 netmask 255.255.255.0 up
# ifconfig enp1s0:0 192.168.0.3 netmask 255.255.255.240 up
# route add default gw 192.168.0.1 enp1s0

Ping to both the IP Address is working fine.

enp1s0    Link encap:Ethernet  HWaddr 3C:E1:A1:3F:21:3F  
          inet addr:192.168.0.2  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::3ee1:a1ff:fe3f:213f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:118 errors:0 dropped:0 overruns:0 frame:0
          TX packets:97 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:13707 (13.3 KiB)  TX bytes:19818 (19.3 KiB)

enp1s0:0  Link encap:Ethernet  HWaddr 3C:E1:A1:3F:21:3F  
          inet addr:192.168.0.3  Bcast:192.168.0.15  Mask:255.255.255.240
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

enp2s0    Link encap:Ethernet  HWaddr 3C:E1:A1:3F:F8:17  
          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)

I then created a file in /etc/systemd/network: enp1s0.network with the following content:

[Match]
Name=enp1s0

[Network]
Address=192.168.0.2/24
Address=192.168.0.3/28
Gateway=192.168.0.1

Ping on both IP Addresses works fine, but i don't see virtual interface on running ifconfig command. When i run the above series of ifconfig commands, i can see them. How to achieve similar output

ifconfig 
enp1s0    Link encap:Ethernet  HWaddr 3C:E1:A1:3F:21:3F  
          inet addr:192.168.0.2  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::3ee1:a1ff:fe3f:213f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:264 errors:0 dropped:3 overruns:0 frame:0
          TX packets:155 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:29991 (29.2 KiB)  TX bytes:27216 (26.5 KiB)

enp2s0    Link encap:Ethernet  HWaddr 3C:E1:A1:3F:F8:17  
          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:128 errors:0 dropped:0 overruns:0 frame:0
          TX packets:128 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:8528 (8.3 KiB)  TX bytes:8528 (8.3 KiB)
1

0

You must log in to answer this question.