Article title: Dual-IP settings for a single NIC in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
1. configure the first IP address:
[Root @ Linux root] # cd/etc/sysconfig/network-scripts
[Root @ Linux network-scripts] # vi ifcfg-eth0
DEVICE = eth0
BOOTPROTO = static
BROADCAST = 192.168.80.255 // * BROADCAST address *//
IPADDR = 192.168.80.189 // * The first IP address *//
NETMASK = 255.255.255.0 // * network mask *//
NETWORK = 192.168.80.0 // * NETWORK segment *//
ONBOOT = yes
: Wq // * save and exit *//
2. copy the first IP address configuration file to the second IP address configuration file and modify the IP address:
[Root @ Linux network-scripts] # cp ifcfg-eth0 ifcfg-eth1
[Root @ Linux network-scripts] # vi ifcfg-eth1
DEVICE = eth0
BOOTPROTO = static
BROADCAST = 192.168.80.255 // * BROADCAST address *//
IPADDR = 192.168.80.199 // * Second IP address *//
NETMASK = 255.255.255.0 // * network mask *//
NETWORK = 192.168.80.0 // * NETWORK segment *//
ONBOOT = yes
: Wq // * save and exit *//
3. restart the NIC:
[Root @ Linux network-scripts] # service network restart
Or:
[Root @ Linux network-scripts] # ifdown eth0
[Root @ Linux network-scripts] # ifup eth0
Or
[Root @ Linux network-scripts] # ifconfig eth0 down
[Root @ Linux network-scripts] # ifconfig eth0 up