1. Modify Nic configuration Edit: vi/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = eth0 # describe the DEVICE alias for the NIC, for example, it is eth0 in the ifcfg-eth0 file
BOOTPROTO = static # set the way for the NIC to obtain the IP address. The possible options are static, dhcp, or bootp, which respectively correspond to the IP address specified by the static state and the IP address obtained through the dhcp protocol, IP addresses obtained through the bootp protocol
BROADCAST = 192.168.0.255 # corresponding subnet BROADCAST address
HWADDR = 00: 07: E9: 05: E8: B4 # physical address of the corresponding Nic
IPADDR = 12.168.0.33 # If you set the method for obtaining the IP address from the network adapter to static, This field specifies the IP address of the network adapter.
NETMASK = 255.255.255.0 # network mask corresponding to the network adapter
NETWORK = 192.168.0.0 # NETWORK address of the NIC
2. Modify the gateway configuration
Edit: vi/etc/sysconfig/network:
NETWORKING = yes (indicates whether the system uses the network, which is generally set to yes. If it is set to no, the network cannot be used, and many system service programs cannot be started)
HOSTNAME = centos (set the host name of the local machine. The host name set here must correspond to the host name set in/etc/hosts)
GATEWAY = 192.168.0.1 (set the IP address of the GATEWAY connected to the local machine .)
The first three items are available by default when I open the editing here, so only GATEWAY is added.
3. Modify DNS configuration
Edit: vi/etc/resolv. conf:
Nameserver is the IP address of the DNS server. The first is the first choice, and the second is the backup.
4. Restart the network service.
Run the following command:
The code is as follows: |
Copy code |
Service network restart or/etc/init. d/network restart |
The above is almost no problem, but I need to set the IPAddress on eth1, and the result will be a problem.
Centos6.4 version installed, found that only eth1 in the system, and/etc/sysconfig/network-scripts/under only ifcfg-eth0 files, although the Internet access, but cannot set static IP.
Solution:
The code is as follows: |
Copy code |
Vi/etc/udev/rules. d/70-persistent-net.rules # This file was automatically generated by the/lib/udev/write_net_rules # Program, run by the persistent-net-generator.rules rules file. # # You can modify it, as long as you keep each rule on a single # Line, and change only the value of the NAME = key. # PCI device 0x8086: 0x100e (e1000) # SUBSYSTEM = "net", ACTION = "add", DRIVERS = "? * ", ATTR {address} =" 08: 00: 27: f2: 31: 9b ", ATTR {type} =" 1 & Prime ;, KERNEL = "eth *", NAME = "eth0 & Prime; # PCI device 0x8086: 0x100e (e1000) SUBSYSTEM = "net", ACTION = "add", DRIVERS = "? * ", ATTR {address} =" 08: 00: 27: 9d: 08: ba ", ATTR {type} =" 1 & Prime ;, KERNEL = "eth *", NAME = "eth1" |
The above one eth0 directly commented out, the following eth1 to eth0, record the corresponding Nic address and then edit the ifcfg-eth0 as follows
The code is as follows: |
Copy code |
DEVICE = eth0 HWADDR = 08: 00: 27: 9D: 08: BA # UUID = accb31df-ac8b-474c-aad8-b1ecd68ad346 NM_CONTROLLED = yes # BOOTPROTO = dhcp BOOTPROTO = static IPADDR = 192.168.0.188 GATEWAY = 192.168.0.1 NETMASK = 255.255.255.0 ONBOOT = yes TYPE = Ethernet DNS1 = 192.168.0.1
|
~
Gateway settings (not required here configured above)
Add the following to the last line of the vi/etc/sysconfig/network file:
The code is as follows: |
Copy code |
GATEWAY = 192.168.0.1 /Etc/init. d/network restart |
Restart the network
Note: add DNS1 or you will not be able to access the Internet (oracle VM installation)