Recently, I have been configuring the CentOS 6.4 server, and configuring LNMP+Django on the server. Although I have been using MAC for development, I still need to investigate a lot of information for the first time configuration on CentOS/RHEL.
- Open the network card configuration file using an editor, here we use eth0 by default.
vi /etc/sysconfig/network-scripts/ifcfg-eth0
Enter the following content
DEVICE=eth0 # Describes the device alias corresponding to the network card, for example, in the ifcfg-eth0 file, it is eth0
ONBOOT=yes # Whether to enable at startup, CentOS is not enabled by default
BOOTPROTO=static # Set to static configuration, optional dhcp or bootp when dynamic IP is required
HWADDR=00:06:E3:0F:62 # Hardware MAC address of the network card
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, optional setting
DNS1=8.8.8.8 # Primary DNS, optional setting
DNS2=8.8.4.4 # Secondary DNS, optional setting
IPV6INIT=no # IPv6 related
IPV6_AUTOCONF=no # IPv6 related
- Modify DNS resolution, edit the resolv.conf file
vi /etc/resolv.conf
Enter
nameserver 8.8.8.8
nameserver 8.8.4.4
- Restart network configuration
service network restart
- Open or close the network
ifup eth0 # Open the network
ifconfig eth0 up # Open the network
ifdown eth0 # Close the network
ifconfig eth0 down # Close the network
- Configure the network service
vi /etc/sysconfig/network
Enter
NETWORKING=yes # Open network service
HOSTNAME=centos # Hostname
GATEWAY=192.168.0.1 # Gateway setting