Modify IP addresses and gateways in Linux

Source: Internet
Author: User

 

Modifying IP addresses and gateways is a common operation. It may cause a lot of unnecessary trouble if you do not set the IP addresses and gateways ..

 

 

1. Modify the IP address
VI/etc/sysconfig/network-scripts/ifcfg-eth0
Device = eth0
Bootproto = none
Broadcast = 192.168.1.255
Ipaddr = 192.168.1.33
Netmask = 255.255.255.0
Network = 192.168.1.0
Onboot = Yes
Userctl = No
Peerdns = No
Type = Ethernet

If there are 2 NICs, the second information is saved in the ifcfg-eth1 file.

 

VI/etc/sysconfig/network-scripts/ifcfg-eth1

Device = eth1
Onboot = Yes
Bootproto = none
Ipaddr = 192.168.2.34
Netmask = 255.255.255.0
Userctl = No
Peerdns = No
Type = Ethernet
Network = 192.168.2.0
Broadcast = 192.168.2.255

 

2. Modify the Gateway
VI/etc/sysconfig/Network

Networking = Yes
Hostname = Aaron
Gateway = 192.168.1.1

 

 

3. Restart the network configuration: After modifying the IP address and gateway, you must restart the network service to make the configuration take effect.
/Etc/init. d/network restart

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.