This article transferred from: Http://www.cnblogs.com/kerrycode/archive/2012/12/17/2821836.html#commentform
Configure dynamic IP
Enter setup in the Terminal Command window and the following window will pop up
[[Email protected] ~]# Setup
Select Network Configuration, click Enter to enter the following screen,
Select the Edit Devices option to enter the following screen
Click Enter, the option to enter the following interface, press TAB to switch between options, select Use DHCP, press the space bar, will appear [*], and then click OK. Note: Sometimes in the name or device options you accidentally, let eth0 more space, will cause configuration problems, at this time you want to check the/etc/sysconfig/network-scripts/ifcfg-eth0 configuration file, to find the problem. Otherwise, this sort of detail will keep you on your own for a long time.
Configure static IP
Configuring a static IP can be done by modifying the configuration document, restarting the network configuration, making it permanent, and using the command to modify it in a timely manner, but after a reboot, the modification fails.
Command modification
[[Email protected] ~] #ifconfig eth0 ***.***.***.*** netmask ***.***.***.*** up
Where up is let the name take effect
Configuration modifications
1: First find the device configuration file, for the first Ethernet device, the configuration file is generally named Ifcfg-eth0, as follows:/etc/sysconfig/network-scripts/ifcfg-eth0
[Email protected] network-scripts]# more Ifcfg-eth0
Device=eth0--Physical setting name, Eth0 is the first network card, if there is a dual network card or more, in turn, eth1, eth*
ipaddr=172.20.32.93 --ip address configuration
netmask=255.255.248.0 &nbs P --Subnet mask configuration
[network=***.***.***.**] -- Network address: Optional
[broadcast=***.***.***.***]--broadcast address: Optional
gateway= 172.20.39.251--Gateway configuration
dns1=172.20.0.11 --dns service configuration
on Boot=yes --whether the device is activated at boot
hwaddr=50:e5:49:df:b0:8b --Physical Address
bootproto=none   --[NONE|STATIC|BOOTP|DHCP] (no protocol at boot | static Assignment | BOOTP protocol | DHCP protocol)
type=ethernet --network type
ipv6init=no-- IPV6
userctl=no--whether a non-root user can control the device /span>
2: Modify Gateway Configuration: Gateway configuration can also be configured in/etc/sysconfig/network-scripts/ifcfg-eth0
[Email protected] sysconfig]# more/etc/sysconfig/network
Networking=yes
Hostname=db-server
gateway=172.20.39.251
3: Modify DNS configuration: DNS configuration can also be configured in/etc/sysconfig/network-scripts/ifcfg-eth0
[Email protected] sysconfig]# more/etc/resolv.conf
NameServer 172.20.0.11
4: Restart the network configuration
4.1
[Email protected] ~]# service network restart #重新启动网络
Shutting down interface eth0: [OK]
Shutting down loopback interface: [OK]
Bringing up loopback interface: [OK]
Bringing Up interface eth0: [OK]
4.2
[[Email protected] ~] #ifdown eth0 #关闭eth0网卡
[[Email protected] ~] #ifup eth0 #启动eth0网卡
Determining IP information for Eth0....done
4.3 Method 3: Use Ifconfig to stop the service
[[Email protected] ~] #ifconfig eth0 down
[[Email protected] ~] #ifconfig eth0 up
Problem Brocade Set
1: See if the NIC is active. If activation can see the IP address
[[Email protected] ~] $ifconfig eth0
Eth0 Link encap:ethernet HWaddr 50:e5:49:df:79:1b
inet addr:172.20.32.93 bcast:172.20.255.255 mask:255.255.248.0
Inet6 ADDR:FE80::52E5:49FF:FEDF:791B/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:6723879 errors:0 dropped:0 overruns:0 frame:0
TX packets:203653 errors:0 dropped:0 overruns:0 carrier:1
collisions:0 txqueuelen:1000
RX bytes:750410997 (715.6 MiB) TX bytes:180711485 (172.3 MiB)
Interrupt:25
If it fails to activate, it can be in the following configuration file Settings .
/etc/sysconfig/network-scrips/ifcfg-eth0
If the host name is set together with the gateway, the/etc/sysconfig/network is also used.
2: Set host name
Need to modify/etc/hosts and/etc/sysconfig/network two files,
/etc/hosts changing host name and IP address correspondence
/etc/sysconfig/network change hostname (hostname) and network card operating status
/etc/sysconfig/networking/profiles/default/hosts
For example:
172.20.32.93 Db-server
127.0.0.1 Db-server
Is it strange that there are ifcfg-eth0 profiles under/etc/sysconfig/networking/profiles/default? Is there a ifcfg-eth0 configuration file under/etc/sysconfig/networking/devices? I don't know what the difference is.
3: Restart Network Service commands for several different systems
RedHat Linux command to reload or restart network (login as root user):
# Service Network Restart
OR
#/etc/init.d/network Restart
To start Linux Network service:
# Service Network Start
To stop the Linux Network service:
# Service Network Stop
Debian Linux command to reload or restart network:
#/etc/init.d/networking Restart
To start Linux Network service:
#/etc/init.d/networking Start
To stop the Linux Network service:
#/etc/init.d/networking Stop
Ubuntu Linux User use sudo command with above Debian Linux command:
# sudo/etc/init.d/networking Restart
To start Linux Network service:
# sudo/etc/init.d/networking Start
To stop the Linux Network service:
# sudo/etc/init.d/networking Stop
Resources:
http://blog.csdn.net/nashviller/article/details/6851930
Http://os.51cto.com/art/201003/186930.htm
Http://www.cnblogs.com/CgenJ/archive/2011/07/28/2119448.html
Linux/redhat Basic Network configuration