Linux IP Changes
1: Temporary modification:
1.1: Modify IP Address
# ifconfig eth1 172.16.1.82
1.2: Modify the gateway address
# route add default GW 192.168.100.1 dev eth0
1.3: Modify DNS
# echo "NameServer 8.8.8.8" >>/etc/resolv.conf
This time will be able to surf the internet, the IP address of the Internet is 192.168.100.100, the gateway address is 192.168.100.1. However, this setting is temporary, once you restart the network card or restart the server,
In addition to 1.3 of the operation will be restored, such a way only suitable for temporary IP modification, want to permanently modify the network card configuration file, you need to modify the corresponding file
2: Permanent modification:
2.1: Modify IP Address
Modify the/etc/sysconfig/network-scripts/ifcfg-eth0 file, if there are more than one network card, then modify the appropriate network card
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0 #网卡对应的设备别名
Bootproto=static #网卡获得ip地址的方式 (default is DHCP, which means auto get)
HWADDR=00:07:E9:05:E8:B4 #网卡MAC地址 (Physical Address)
ipaddr=192.168.100.100 #IP地址
netmask=255.255.255.0 #子网掩码
Onboot=yes #系统启动时是否激活此设备
2.2: Modify the gateway address
Modify the/etc/sysconfig/network file
# vi/etc/sysconfig/network
Networking=yes #表示系统是否使用网络, no means network is not available
Hostname=doiido #设置本机的主机名 to be the same as the host name set in/etc/hosts
gateway=192.168.100.1 #设置网关的IP地址
You can ping the IP address at this time, but you cannot ping the domain name, so you need to modify the DNS
2.3: Modify DNS
Modify the/etc/resolv.conf file
# vi/etc/resolv.conf
NameServer 8.8.8.8 #google域名服务器
NameServer 114.144.114.114 #国内域名服务器
2.4: Restart the NIC
# Service Network Restart
Shutting down interface eth0: [OK]
Close Loopback interface: [OK]
Eject loopback interface: [OK]
Popup interface eth0: [OK]
This time, the system will be able to surf the internet properly.
Linux IP Changes