ifconfig 英文全拼network interfaces configuring,显示或配置网络设备。
ifconfig

127.0.0.1这个ip可以访问你自己电脑,这个叫做本地回环




临时性的将ens38这个网卡关掉:(重启之后又是可以使用的!)
sudo ifconfig ens38 down

开启网卡:
sudo ifconfig ens38 up

修改ens33网卡的ip地址:(这也是临时性的修改,重启之后也会失效)

sudo ifconfig ens33 192.168.30.233

这里设置的是动态ip。
sudo vi /etc/network/interfaces

显示只配置了一个本地回环的!

修改好之后需要重启之后才能生效:
reboot
修改dns解析
因为以前是dhcp解析,所以会自动分配dns服务器地址,而一旦设置为静态ip后,就没有自动获取到的dns服务器了,要自己设置一个:
sudo vi /etc/resolv.conf
写上一个公网的DNS:
nameserver 114.114.114.114

重启网卡:
sudo /etc/init.d/networking restart
如果还不生效重启系统!
ping脉冲,向远端IP地址发送ICMP(Internet Control Message Protocol)协议的数据包,检测网络状态;
where@ubuntu:~$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=128 time=453 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=128 time=5.86 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=128 time=35.7 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=128 time=5.33 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=128 time=4.37 ms
64 bytes from 192.168.1.1: icmp_seq=6 ttl=128 time=3.54 ms
也可以向域名发送数据包:
where@ubuntu:~$ ping www.baidu.com
PING www.a.shifen.com (14.215.177.37) 56(84) bytes of data.
64 bytes from 14.215.177.37: icmp_seq=1 ttl=128 time=18.2 ms
64 bytes from 14.215.177.37: icmp_seq=2 ttl=128 time=14.4 ms
64 bytes from 14.215.177.37: icmp_seq=3 ttl=128 time=12.3 ms
64 bytes from 14.215.177.37: icmp_seq=4 ttl=128 time=23.0 ms
查看当前网络接口信息。
‐a #显示所有socket,包括正在监听的。
‐c #每隔1秒就重新显示一遍,直到用户中断它。
‐n #以网络IP地址代替名称,显示出网络连接情形,显示端口。
‐t #显示TCP协议的连接情况。
‐u #显示UDP协议的连接情况。
‐p #显示建立相关链接的程序名。
‐l #查看正在处于监听状态的程序。
#LISTEN和LISTENING的状态只有用‐a或者‐l才能看到
看tcp和udp协议:

sudo netstat -anp | grep apache

80表示80端口,前面的0表示任意的ip都可以访问。
sudo netstat -lnp #查看正在处于监听状态的程序
