1.traceroute 域名/ip
跟踪路由
2.ifconfig
查看ip
3.修改ip
1) Setup(永久的,修改之后/etc/rc.d/init.d/network restart 重启网卡) 2) ifconfig eh0 ip (立马生效;但是是临时的,修改之后重启失效) ifconfig eth0 network ip(子网掩码修改) 3) vi /etc/sysconfig/network-scripts/ifcfg-eth0 (永久的,修改之后/etc/rc.d/init.d/network restart 重启网卡) |
4.netstat 用于查看进程端口的网络连接情况
1)用法netstat -h
[root@Oracle ~]# netstat -h usage: netstat [-veenNcCF] [<Af>] -r netstat {-V|--version|-h|--help} netstat [-vnNcaeol] [<Socket> ...] netstat { [-veenNac] -I[<Iface>] | [-veenNac] -i | [-cnNe] -M | -s } [delay]
-r, --route display routing table -I, --interfaces=[<Iface>] display interface table for <Iface> -i, --interfaces display interface table -g, --groups display multicast group memberships -s, --statistics display networking statistics (like SNMP) -M, --masquerade display masqueraded connections
-v, --verbose be verbose -n, --numeric don't resolve names//以数字的形式展示,用IP和端口的形式展示连接状态 --numeric-hosts don't resolve host names --numeric-ports don't resolve port names --numeric-users don't resolve user names -N, --symbolic resolve hardware names -e, --extend display other/more information -p, --programs display PID/Program name for sockets//显示进程名 -c, --continuous continuous listing
-l, --listening display listening server sockets//只显示监听中的网络连接 -a, --all, --listening display all sockets (default: connected)//显示所有网络连接 -o, --timers display timers -F, --fib display Forwarding Information Base (default) -C, --cache display routing cache instead of FIB -T, --notrim stop trimming long addresses -Z, --context display SELinux security context for sockets
<Iface>: Name of interface to monitor/list. <Socket>={-t|--tcp} {-u|--udp} {-S|--sctp} {-w|--raw} {-x|--unix} --ax25 --ipx --netrom <AF>=Use '-A <af>' or '--<af>'; default: inet List of possible address families (which support routing): inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP) x25 (CCITT X.25) |
2)输入netstat -an(以数字的形式显示所有网络连接)
[root@Oracle ~]# netstat -an Active Internet connections (servers and established) 协议 本地IP:端口 远程IP:端口 状态 Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:5801 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:862 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN tcp 0 0 :::6001 :::* LISTEN tcp 0 0 :::22 :::* LISTEN tcp 0 0 ::ffff:192.168.126.100:22 ::ffff:192.168.126.1:50912 ESTABLISHED udp 0 0 0.0.0.0:856 0.0.0.0:* udp 0 0 0.0.0.0:859 0.0.0.0:* udp 0 0 0.0.0.0:5353 0.0.0.0:* udp 0 0 0.0.0.0:111 0.0.0.0:* udp 0 0 0.0.0.0:49525 0.0.0.0:* udp 0 0 0.0.0.0:631 0.0.0.0:* udp 0 0 :::16826 :::* udp 0 0 :::5353 :::* Active UNIX domain sockets (servers and established) Proto RefCnt Flags Type State I-Node Path unix 2 [ ACC ] STREAM LISTENING 13191 @/tmp/fam-root- unix 18 [ ] DGRAM 9740 /dev/log unix 2 [ ACC ] STREAM LISTENING 10455 @/var/run/hald/dbus-zYl86Ji68f unix 2 [ ACC ] STREAM LISTENING 9684 /var/run/audispd_events unix 2 [ ACC ] STREAM LISTENING 10173 /var/run/dbus/system_bus_socket unix 2 [ ACC ] STREAM LISTENING 10281 /var/run/sdp unix 2 [ ACC ] STREAM LISTENING 10376 /var/run/pcscd.comm unix 2 [ ACC ] STREAM LISTENING 10411 /var/run/acpid.socket |
注意:1.状态一般包含以下几种:
LISTEN :在监听状态中。
ESTABLISHED:已建立联机的联机情况。
TIME_WAIT:该联机在目前已经是等待的状态。
3)查询某个端口是否已被占用
Netstat -an | grep 端口号
[root@Oracle ~]# netstat -an | grep 22 tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN tcp 0 0 :::22 :::* LISTEN tcp 0 52 ::ffff:192.168.126.100:22 ::ffff:192.168.126.1:50912 ESTABLISHED |
4)查询某个查询所使用的端口
Netstat -ap | grep 程序名
[root@Oracle ~]# netstat -ap | grep Oracle getnameinfo failed getnameinfo failed tcp 0 0 Oracle:2208 *:* LISTEN 3936/hpiod tcp 0 0 Oracle:ipp *:* LISTEN 3011/cupsd tcp 0 0 Oracle:smtp *:* LISTEN 4001/sendmail: acce tcp 0 0 Oracle:2207 *:* LISTEN 3941/python
|
5.ping 用于检测本机远程的连接状态,但是这里需要说明一下ping命令有时候对远程机器ping不通,但是客户端却可以连接,这是因为远程服务器把ping服务关了,以防止恶意ping而占用带宽
Ping IP -t
Ping 本机 ,能ping通表示网卡正常
Ping 网关,能ping通,表示网线连接正常
LINUX下禁止ping命令的使用
以root进入Linux系统,然后编辑文件icmp_echo_ignore_all vi /proc/sys/net/ipv4/icmp_echo_ignore_all 将其值改为1后为禁止PING 将其值改为0后为解除禁止PING
直接修改会提示错误:
WARNING: The file has been changed since reading it!!! Do you really want to write to it (y/n)?y "icmp_echo_ignore_all" E667: Fsync failed Hit ENTER or type command to continue
这是因为 proc/sys/net/ipv4/icmp_echo_ignore_all 这个不是真实的文件 如果想修改他的数值可以echo 0 或 1到这个文件
(即echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all )。要是想永久更改可以加一行
net.ipv4.icmp_echo_ignore_all=1 到配置文件/etc/sysctl.conf里面 |