Linux OPS Notes
Configure IP
There are two main ways of configuring IP
1. Immediate effect, temporary modification
Ifconfig eth0 (NIC name) 10.0.0.211 (IP address) netmask 223.5.5.5 (subnet mask)
2. Restart effective, permanent modification
Vim or VI enters into/ETC/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-ETH0 (network card configuration file)
The configurations added or modified are as follows:
ipaddr=10.0.0.211
netmask=255.0.0.0
gateway=10.0.0.254
dns1=223.5.5.5
dns2=114.114.114.114
We can view the gateway through NETSTAT-RN,
The netstat command is to view the port, the R (Kernel IP routing table) option is to display the routing table, and the N option refers to the direct use of the IP address instead of the DNS domain name server.
[Email protected] ~]# Netstat-rn
Kernel IP Routing Table
Destination Gateway genmask Flags MSS Window Irtt Iface
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 10.0.0.254 0.0.0.0 UG 0 0 0 eth0
Modify the default gateway
1. Immediate effect, temporary modification
Route add default GW 10.0.0.254
2. Restart effective, Permanent
VI or VIM into the/etc/sysconfig/network-scripts/ifcfg-eth0
Join
gateway=10.0.0.254
Errors encountered in adding or modifying a gateway
Siocaddrt:no such process add route error
Reason
The gateway to add or modify is not the same as the network segment where the host or IP resides.
For example, the gateway I want to add is 192.168.1.200, but my host does not have 192.168.1 segments of the NIC, only one 10.0.0 NIC.
Later on the simplest way to change 192.168.1.200 to 10.0.0.254, so that my host or IP is on the same network segment.
In fact, you can add a 10.0.0 segment of the network card, and then add the gateway.
sudo route add 196.168.1.200/32 dev eth0
sudo route add default GW 196.168.1.200
In addition to the IP, subnet mask, gateway, DNS configuration, you also need to modify or add the network card name, device name, Bootproto (only in static mode can use the set of IP information), Onboot,type and other important configuration information
ipaddr=10.0.0.211
netmask=255.0.0.0
gateway=10.0.0.254
dns1=223.5.5.5
dns2=114.114.114.114
Name=eth0
Device=eth0
Bootproto=static
Onboot=yes
Type=ethernet
Modify DNS
Restart effective, permanent modification
VI or VIM into the/etc/sysconfig/network-scripts/ifcfg-eth0
Add to
dns1=223.5.5.5
dns2=223.6.6.6
Or it can be modified in the DNS configuration file.
DNS in the NIC configuration file takes precedence over the DNS configuration.
Note: For private reference only!!!
Linux Transport Koriyuki Configuration IP