How to modify IP address under Linux

Source: Internet
Author: User

How to modify IP information under Linux systems

I used to change it with ifconfig, and I always have to redo it after reboot. If you modify the configuration file, it will not be so troublesome ~

A, modify the IP address

Immediate effect:

# ifconfig eth0 192.168.0.20 netmask 255.255.255.0

Activation takes effect:

Modify/etc/sysconfig/network-s/ifcfg-eth0

B. Modify the default gateway

Immediate effect:

# route add default GW 192.168.0.254

Activation takes effect:

Modify/etc/sysconfig/network-s/ifcfg-eth0

C. Modify DNS

Modify/etc/resolv.conf

Modified to take effect immediately, start the same effective

D. Modify Host Name

Immediate effect:

# hostname FC2

Activation takes effect:

Modify/etc/sysconfig/network

New Boot Network configuration

/etc/init.d/network restart

Prerequisite: Redhat System

IP, Mask:

Edit/etc/sysconfig/network-script/ifcfg-eth0
ipaddr=192.168.0.1
netmask=255.255.255.0

Gateway:

Edit/etc/sysconfig/network
Networking=yes
Hostname=xx
gateway=192.168.0.100
Dns:

Edit/etc/resolv.conf
nameserver=202.96.209.5
Note: The above IP address should be changed to the IP address corresponding to your network configuration.

Modify NIC IP and gateway under Linux
It is recommended to modify the terminal character mode.
A modified 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
~
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
Two modification gateways
Vi/etc/sysconfig/network
Networking=yes
Hostname=aaron
gateway=192.168.1.1
Three Restart network configuration
/etc/init.d/network restart



——————————————————————————

Modifying a configuration file
Config file under/etc/sysconfig/network-scripts/
For example file: Ifcfg-eth0 representative is the Ethernet actual NIC 0 configuration file
For example file: IFCFG-ETH0:1 representative is the Ethernet actual NIC 0 configuration file
Domain Name server configuration file:/etc/resolv.conf
Modify IP Address
Immediate effect:
# ifconfig eth0 192.168.0.20 netmask 255.255.255.0
Activation takes effect:
Modify/etc/sysconfig/network-scripts/ifcfg-eth0
Modify the default gateway
Immediate effect:
# route add default GW 192.168.0.254
Activation takes effect:
Modify/etc/sysconfig/network-scripts/ifcfg-eth0
Modify DNS
Modify/etc/resolv.conf
Modified to take effect immediately, start the same effective
Modify Host Name
Immediate effect:
# hostname FC2
Activation takes effect:
Modify/etc/sysconfig/network

How to modify the IP address under Linux

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.