1. Set up dynamic IP
Ifconfig eth0 192.168.1.12
is set to take effect immediately after restarting the machine.
2. Set the static IP
Edit File/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0
Bootproto=dhcp
Onboot=yes
hwaddr=00:0c:29:16:e5:8c
Add to:
ipaddr=192.168.1.12
netmask=255.255.255.0
gateway=192.168.1.1
Type=ethernet
Two lines, change the bootproto=dhcp to bootproto=static, note that the Bootproto value must be modified to static (static), modified after the restart of the server (reboot) to take effect, restart the network can also: Service network Restart
Ifcfg-eth0 content is as follows:
[Email protected] ~]# cd/etc/sysconfig/network-scripts/
[email protected] network-scripts]# cat Ifcfg-eth0
# Marvell Technology Group Ltd. Unknown device 4380
Device=eth0
Bootproto=static
ipaddr=192.168.1.12
netmask=255.255.255.0
gateway=192.168.1.1
Onboot=yes
#TYPE =ethernet
#DNS1 =8.8.8.8
Second, modify the gateway
Vi/etc/sysconfig/network
Networking=yes
Hostname=aaron
gateway=192.168.1.1
Third, modify the DNS
$ vi/etc/resolv.conf
NameServer 192.168.1.1
NameServer 8.8.8.8
View Network, Gateway
# IP Route Show # View Route pointing
10.211.55.0/24 Dev eth0 proto kernel scope link src 10.211.55.12
Default via 10.211.55.1 Dev eth1
# netstat-rn # Querying network data structures
# route-n # Querying network data Structures (tests are the same as Netstat display results)
1.lsmod check whether the module of the NIC is loaded to see if the NIC driver is good
2.DMESG: Check to see if the network card is detected.
3.ifup Ifdown activating/stopping network card
Linux static IP Dynamic IP settings