Recently, I have been tossing the CentOS6.4 server configuration, and I have been configuring LNMP + Django on the server.
Although I have been using MAC for development, the configuration in CentOS/RHEL for the first time still needs to be investigated.
1. Use the editor to open the Nic configuration file. eth0 is used by default.
The code is as follows: |
Copy code |
Vi/etc/sysconfig/network-scripts/ifcfg-eth0 |
Enter the following content
The code is as follows: |
Copy code |
DEVICE = eth0 # describe the DEVICE alias for the NIC, for example, it is eth0 in the ifcfg-eth0 file ONBOOT = yes # enable or not at startup. CentOS is disabled by default. BOOTPROTO = static # set it to static configuration. dhcp or bootp is optional when you need to obtain the ip address dynamically. HWADDR = 00: 06: E3: 0F: 62: EF # hardware MAC address of the NIC IPADDR = 192.168.0.100 # IP address BROADCAST = 192.168.0.255 # corresponding subnet BROADCAST address NETMASK = 255.255.255.0 # subnet mask NETWORK = 192.168.0.0 # NETWORK address GATEWAY = 192.168.0.1 # GATEWAY address, which can be set DNS1 = 8.8.8.8 # Main DNS, optional DNS2 = 8.8.4.4 # backup DNS, optional IPV6INIT = no # IPv6 related IPV6_AUTOCONF = no # IPv6 related |
2. Modify DNS resolution and edit the resolv. conf file.
The code is as follows: |
Copy code |
Vi/etc/resolv. conf Type Nameserver 8.8.8.8 Nameserver 8.8.4.4 |
3. Restart the network configuration
The code is as follows: |
Copy code |
Service network restart |
4. Enable or disable the network
The code is as follows: |
Copy code |
Ifup eth0 # open the network Ifconfig eth0 up # open the network Ifdown eth0 # Disable the network Ifconfig eth0 down # Disable the network |
5. Configure the network service
The code is as follows: |
Copy code |
Vi/etc/sysconfig/network |
Type
The code is as follows: |
Copy code |
NETWORKING = yes # enable the network service HOSTNAME = centos # host name GATEWAY = 192.168.0.1 # GATEWAY settings |