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