Linux modifies IP addresses and gateways

Source: Internet
Author: User

Modifying the IP address and gateway is a very common operation, when doing related experiments, if not set up, will bring a lot of unnecessary trouble.

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 network cards, 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 you modify the IP and gateway, you must restart the Network service before it takes effect.
/etc/init.d/network restart

From: http://blog.csdn.net/tianlesoftware/article/details/5312646

Linux modifies IP addresses and gateways

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.