I believe you have met the NIC configuration of the CentOS system. Most of the time there is only one Nic mode, but sometimes we need two NICs, for example, when configuring a database cluster, how can we configure a floating IP address? With this problem, we will gradually implement the configuration process of Dual-nic.
I. system environment:
1. CentOS: 32-bit version 6.3;
2. Virtual Machine: VMware®Workstation 9.0.0 build-812388;
Ii. configuration process:
1. View Nic Configuration:
[Root @ localhost ~] # Ifconfig-
Display result:
Eth0 Link encap: Ethernet HWaddr 00: 0C: 29: E6: 68: 51
Inet addr: 192.168.31.132 Bcast: 192.168.31.255 Mask: 255.255.255.0
Inet6 addr: fe80: 20c: 29ff: fee6: 6851/64 Scope: Link
Up broadcast running multicast mtu: 1500 Metric: 1
RX packets: 98 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 119 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 FIG: 1000
RX bytes: 21284 (20.7 KiB) TX bytes: 15269 (14.9 KiB)
Interrupt: 19 Base address: 0x2024
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: 16436 Metric: 1
RX packets: 16 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 16 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 txqueuelen: 0
RX bytes: 960 (960.0 B) TX bytes: 960 (960.0 B)
2. All configurations of Linux and Unix systems are implemented in files. Let's take a look at how Nic and IP configurations of Centos are implemented, open the/etc/sysconfig/network-scripts directory:
[Root @ localhost ~] # Cd/etc/sysconfig/network-scripts
[Root @ localhost network-scripts] # ls-ls
-Rw-r --. 1 root 287 Mar 6 ifcfg-eth0
Through the ls-ls command we can see that there is a ifcfg-eth0 file, this is the network IP configuration file we are looking. So let's see what's in it?
[Root @ localhost network-scripts] # ifcfg-eth0 more
DEVICE = "eth0"
# BOOTPROTO = "dhcp"
BOOTPROTO = "static"
HWADDR = "00: 0C: 29: E6: 68: 51"
# Define 6init = "yes"
IPV6INIT = "no"
IPADDR = "192.168.31.132"
NM_CONTROLLED = "yes"
ONBOOT = "yes"
TYPE = "Ethernet"
UUID = "5ea8440a-4031-4d99-9adf-f810ed05a215"
DNS1 = 192.168.31.2
# DEVICE = eth0
# BOOTPROTO = dhcp
# ONBOOT = yes
In the file, we see the driver, IP address, DNS server, and other configuration information of the NIC seen by the ifconfig command execution. Of course, this is my previously configured file. Can we configure a network IP address like this? The answer is yes. How should I configure it? Please go down:
3. Configure the Virtual Machine network adapter:
A: VM menu: VM --> Setting.... Open the VM Setting interface ,:
B: Select the "Add" button. In the displayed dialog box, select the "Network Adapter" option ,:
C: click "Next". In the displayed dialog box, select the "Bridged" option ,:
D: click the "Finish" button to return to the main interface and you will see the newly created Nic Adapter "Network Adapter 2 ".