Details of linux network parameter configuration method

  • 2020-05-07 20:46:14
  • OfStack

Main USES:
1. View the network interface Settings: ifconfig, a, or a, ifconfig
ifconfig   network interface   [add/del]   IP address   netmask   subnet mask example: ifocnfig eth0 10.2.3.4 [netmask 255.255.255.0]
3. Activation/shutdown format of network interface: ifconfig network interface up/down
Configuration dns
Create /etc/ resolv.conf file and write DNS server address in it
Configure hostname
Configure the /etc/sysconfig/network file while changing the hostname using hostname
Examples of use:


[root@twin0898 sysconfig]# cat network
network          networking/      network-scripts/ 
[root@twin0898 sysconfig]# cat network
NETWORKING=yes
GATEWAY=125.39.149.1
HOSTNAME=twin0898
NETWORKING_IPV6=no

General format:
1. Gateway to network route   add/delete  -net   target network   netmask   mask     gw   gateway address   [dev   network interface]
2. Gateway route   add/delete  -host   target host   gw   gateway   [dev   network interface]
Add default gateway: route   add   default   gw   gateway address check host routing table: route, netstat-nr
// the summary is as follows:
1. Network configuration check: ifconfig-a
2. Connectivity check: ping, traceroute
3. Route table check: route or netstat, nr
4. Check the running status of DNS client: nslookup
// examples of use are as follows
// ifconfig -a


root@CinemaTest2:/usr/local/jdk# ifconfig -a
eth0      Link encap:Ethernet  HWaddr b8:ac:6f:38:10:c6  
          inet addr:192.168.232.127  Bcast:192.168.232.255  Mask:255.255.255.0
          inet6 addr: fe80::baac:6fff:fe38:10c6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:42918159 errors:0 dropped:0 overruns:0 frame:0
          TX packets:40893832 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:30644395811 (30.6 GB)  TX bytes:30932951131 (30.9 GB)
          Interrupt:16 
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:917 errors:0 dropped:0 overruns:0 frame:0
          TX packets:917 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:81417 (81.4 KB)  TX bytes:81417 (81.4 KB)

// ping vip.ofstack.com


PING movie.kankan.co.sandai.net (114.80.189.60) 56(84) bytes of data.
64 bytes from 114.80.189.60: icmp_seq=1 ttl=54 time=31.2 ms
64 bytes from 114.80.189.60: icmp_seq=2 ttl=54 time=29.9 ms
64 bytes from 114.80.189.60: icmp_seq=3 ttl=54 time=31.1 ms
64 bytes from 114.80.189.60: icmp_seq=4 ttl=54 time=30.5 ms
64 bytes from 114.80.189.60: icmp_seq=5 ttl=54 time=31.4 ms
64 bytes from 114.80.189.60: icmp_seq=6 ttl=54 time=32.6 ms
64 bytes from 114.80.189.60: icmp_seq=7 ttl=54 time=30.8 ms
64 bytes from 114.80.189.60: icmp_seq=8 ttl=54 time=30.9 ms
64 bytes from 114.80.189.60: icmp_seq=9 ttl=54 time=32.0 ms
64 bytes from 114.80.189.60: icmp_seq=10 ttl=54 time=31.3 ms
64 bytes from 114.80.189.60: icmp_seq=11 ttl=54 time=31.3 ms
64 bytes from 114.80.189.60: icmp_seq=12 ttl=54 time=30.3 ms
--- movie.kankan.co.sandai.net ping statistics ---
12 packets transmitted, 12 received, 0% packet loss, time 11004ms
rtt min/avg/max/mdev = 29.954/31.148/32.608/0.704 ms

// netstat -nr


root@CinemaTest2:/usr/local/jdk# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.232.2   0.0.0.0         UG        0 0          0 eth0
192.168.232.0   0.0.0.0         255.255.255.0   U         0 0          0 eth0

// nslookup vip.ofstack.com


root@CinemaTest2:/etc# nslookup vip.ofstack.com
Server:         192.168.8.150
Address:        192.168.8.150#53
Non-authoritative answer:
vip.ofstack.com  canonical name = movie.ofstack.com.
movie.ofstack.com        canonical name = movie.kankan.co.sandai.net.
Name:   movie.kankan.co.sandai.net
Address: 114.80.189.60
Name:   movie.kankan.co.sandai.net
Address: 119.147.41.209


Related articles: