Recently, I finally had a hard time worrying about the existence of centos5.6 on my PC for three months. It was a long journey, and the Linux road started.
Boot With grub, c5.6 boot, in the network that, each loading is very slow. You cannot access the Internet after starting the instance. You can ping the gateway and unreachable on the terminal.
So I slowly suspected that the network information configured in the lab was correct.
1. Detection
Terminal input # ifconfig, found that the configuration information is quite messy, IP is not set, gateway, bootmask is not set.
2. Configuration
(1) Use commands to directly configure the configuration. The advantages are convenient and fast, and the disadvantages are that the configuration cannot be saved. You must reconfigure the configuration every time you restart the instance.
# Up eth0 <! -- Activate the NIC -->
# Down eth0 <! -- Disable Nic -->
# Ifconfig eth0 192.168.1.135 <! -- Configure IP -->
# Route add default GW 192.168.1.1 <! -- Configure the default gateway -->
# Ifconfig netmask 255.255.255.0 up <! -- Set the subnet mask (effective immediately) -->
For more configuration information, refer to: Baidu Library Linux configuration command
(2) rewrite the configuration file. The advantage is that it is valid once and for a long time. Disadvantage? It is not suitable for beginners.
# Vim/etc/sysconfig/Network
# I <! -- Vim insert a shortcut command -->/* append :*/
Networking = Yes
Networking_ipv6 = Yes
Hostname = localhost. localdomain
Gateway = 192.168.1.1
[ESC]
# ZZ (uppercase, VIM command, save and Exit)
# Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Append->
Device = eth0
Hwaddr = 6C: 62: 6d: EB: C9: CD
Ipaddr = 192.168.1.156
Netmask = 255.255.255.0
Gateway = 192.168.1.1
Onboot = Yes
Type = Ethernet
Bootproto = static
# ZZ exits vim, Ping 192.168.1.1 is normal, Ping 8.8.8.8 is normal, and Ping Baidu.com is normal
Now that the configuration is complete, you can access the Internet normally.
One point is that during the configuration process, I write ipaddr as ipadder, which leads to the error of can't specify device or ipaddr!
Careful, bloody lessons, and the Post Method Used in Ajax last night, while the PHP script received it with $ _ get. I am really a talented person!