How to modify IP addresses and gateways in Linux

Source: Internet
Author: User

Modify IP address and gateway is a very common operation, in doing related experiments, if not set well, will bring a lot of unnecessary trouble.

1. Modify 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 you have 2 network adapters, the second information is stored 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

Netwo

Modify IP address and gateway is a very common operation, in doing related experiments, if not set well, will bring a lot of unnecessary trouble.

1. Modify 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 you have 2 network adapters, the second information is stored 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 Gateway

Vi/etc/sysconfig/network

Networking=yes

Hostname=aaron

gateway=192.168.1.1

3. Restart Network configuration: After modifying the IP and gateway, restart the Network service before it takes effect.

/etc/init.d/network restart

rk=192.168.2.0

broadcast=192.168.2.255

2. Modify Gateway

Vi/etc/sysconfig/network

Networking=yes

Hostname=aaron

gateway=192.168.1.1

3. Restart Network configuration: After modifying the IP and gateway, restart the Network service before it takes effect.

/etc/init.d/network restart

This article URL address: http://www.bianceng.cn/OS/Linux/201410/45489.htm

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.