Linux IP Changes

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.