How to modify IP addresses in Linux

Source: Internet
Author: User
In Linux, how can I modify the IP address information is always changed using ifconfig, and always had to be redone after restart. If you modify the configuration file, you don't have to worry about it ~ A. modify the IP address to take effect immediately: # enable ifconfigeth0192.168.0.20netmask0000255.255.0... how can I modify the IP address information in Linux?
 
In the past, ifconfig was always used for modification, and it had to be redone after restart. If you modify the configuration file, you don't have to worry about it ~
 
A. modify the IP address
 
Effective immediately:
 
# Ifconfig eth0 192.168.0.20 netmask 255.255.255.0
 
Start effective:
 
Modify/etc/sysconfig/network-s/ifcfg-eth0
 
B. modify the default gateway
 
Effective immediately:
 
# Route add default gw 192.168.0.254
 
Start effective:
 
Modify/etc/sysconfig/network-s/ifcfg-eth0
 
C. modify dns
 
Modify/etc/resolv. conf
 
The modification takes effect immediately and starts as well.
 
D. modify the host name.
 
Effective immediately:
 
# Hostname fc2
 
Start effective:
 
Modify/etc/sysconfig/network
 
New startup network configuration
 
/Etc/init. d/network restart
 
Premise: Redhat system
 
Ip address, 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 addresses must be changed to the IP address corresponding to your network configuration.
 
Modify the nic ip address and Gateway in Linux
We recommend that you use the terminal character to modify it.
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
~
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
/Etc/init. d/network restart
 
 
 
--------------------------
 
Modify configuration file
/Etc/sysconfig/network-scripts/has a configuration file
For example, the File: ifcfg-eth0 represents the configuration file of the actual Ethernet NIC 0
For example, the File: ifcfg-eth0: 1 represents the actual Ethernet NIC 0 configuration file
Domain Name Server Configuration File:/etc/resolv. conf
Modify IP address
Effective immediately:
# Ifconfig eth0 192.168.0.20 netmask 255.255.255.0
Start effective:
Modify/etc/sysconfig/network-scripts/ifcfg-eth0
Modify the default gateway
Effective immediately:
# Route add default gw 192.168.0.254
Start effective:
Modify/etc/sysconfig/network-scripts/ifcfg-eth0
Modify dns
Modify/etc/resolv. conf
The modification takes effect immediately and starts as well.
Modify host name
Effective immediately:
# Hostname fc2
Start effective:
Modify/etc/sysconfig/network
 

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.