CentOS Network Configuration-Setup a new NIC

Environment:

CentOS6 minimal install without XWindow

 

To permanent change the IP, Submask, DNS etc

 

Step 1: Configure Hostname

 

cd /etc/sysconfig
vi network

# Modify HOSTNAME:

 HOSTNAME=myHostname

 

Step 2: Configure NIC

cd /etc/sysconfig/network-scripts
# There may have different filenames in different computers.
# But the naming rule is ifcfg-*
vi ifcfg-eth0

# Add the following K/V pair

 

# NIC name

DEVICE=LocalNIC

IPADDR=192.168.1.200
SUBMASK=255.255.255.0
GATEWAY=192.168.1.1
HWADDR=00:0C:29:42:59:92
NM_CONTROLLED=yes

# Turn this when you need this NIC enable when system startup

# If this option is NO. That means you can not access network by this NIC.
ONBOOT=yes

 

Step 3 : Configure DNS

cd /etc
vi resolv.conf

# Add the following K/V pair

# You can add most 3 DNS server here.

nameserver 8.8.8.8

nameserver 8.8.4.4

 

Step 4 : Reboot computer and check you network

 

To temporary change your network configuration you can use the following commands

 

Set IP address

 

ifconfig eth0 192.168.1.2 submask 255.255.255.0

 

Set gateway

 

route add default gw 192.168.1.1

 

Set DNS server

 

Ref Step 3

 

****************************************************************************

 

If you are using VMWare. The vm's MAC addr can not be changed like above.

Or you will be 

You should modify the vm's ".vmx" file.

 

Find out the "Your_VM_Name.vmx" file in your vm dir.

Use text editor (Notepad or vi) open that file.

 

Locate those line:

ethernet0.generatedAddress = "00:0c:29:ea:00:72"

uuid.location = "56 4d 8b 23 04 2e b0 64-5f cd a3 12 c3 ea 00 72"

uuid.bios = "56 4d 8b 23 04 2e b0 64-5f cd a3 12 c3 ea 00 72"

 

The value of "ethernet0.generatedAddress" in this format "00:0c:29:??:??:??"

DO NOT change the first 6 chars!

 

For "uuid.bios", you can only change the last 6 char.

Set the same value as "ethernet0.generatedAddress"

 

Save this vmx file and start your vm. you will find the MAC had been changed.

你可能感兴趣的:(centos)