network tool

19.1 Network Tools

19.1.1 ifconfig

19.1.2 ping 19.1.3 netstat

sudo ifconfig eth0 down/up
sudo ifconfig eth0 192.168.102.123

-a (all) displays all options, default does not display LISTEN related
-t (tcp) only displays tcp related options
-u (udp) only displays udp related options
-n refuses to display aliases, can display all numbers converted into numbers. -l List only services that are in Listen (listening)

-p Display the program name that established the relevant link -r Display routing information, routing table
-e Display extended information, such as uid, etc. -s Statistics are performed by each protocol

-c Execute the netstat command every fixed time.

Tip: The status of LISTEN and LISTENING can only be seen with -a or -l

sudo netstat -anp | grep ftp

19.1.4 Set IP

* Configure the network card by DHCP

220 Chapter 19  Tools

Edit the file /etc/network/interfaces:

and replace the line about eth0 with the following line:

# The primary network interface - use DHCP to find our address

auto eth0
iface eth0 inet dhcp

  Use the following command to make the network settings take effect:

sudo /etc/init.d/networking restart

You can also directly enter the following command on the command line to get the address

sudo dhclient eth0

* Configure a static IP address for the network card 

(1) Edit the file /etc/network/interfaces:

and replace the line about eth0 with the following line:

# The primary network interface auto eth0
iface eth0 inet static
address 192.168.2.1

gateway 192.168.2.254 netmask 255.255.255.0 #network 192.168.2.0 #broadcast 192.168.2.255

(2) Replace the above ip address and other information with your own. Use the following command to make the network settings take effect:

sudo /etc/init.d/networking restart

3. Set DNS
To access the DNS server for query, you need to set the /etc/resolv.conf file. Assuming that the IP address of the DNS server is 192.168.2.2, then the content of the /etc/resolv.conf file should be:

nameserver 192.168.2.2

Manually restart the network service:

udo /etc/init.d/networking restart

s

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325809724&siteId=291194637