Linux网络(一)

[root@localhost ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:78:F6:12
          inet addr:172.17.4.128  Bcast:172.17.4.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe78:f612/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1184 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2104 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:81008 (79.1 KiB)  TX bytes:254489 (248.5 KiB)

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:16436  Metric:1
          RX packets:1431 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1431 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2506048 (2.3 MiB)  TX bytes:2506048 (2.3 MiB)

# inet addr  ip地址
# Bcast     广播地址
# Mask     子网掩码
# HWaddr    mac地址
# lo      回环地址
  

查看某一个网卡的信息 ifconfig eth0

ethN  以太网接口

lo    本地回环

sitN   ipv6地址网卡接口

fddN  光纤网卡

pppN   ADSL宽带或VPN连接

查看本机路由表

route -n  -n显示数字地址

查看本机ARP缓存表

arp -an  -a列出所有条目 -n显示数字地址

可以查看出ip地址和mac地址的对应 *在局域网内,通过ping一下对方的ip 再次查看arp就可以看到对应的mac地址

查看网络连接信息

netstat -anptu  -a显示所有获得连接 -n以数字形式显示 -p显示进程信息 -t/-u 查看tcp/udp连接

路由追踪

tracert --> traceroute 能查看到经过的所有节点

tracert www.baidu.com

测试DNS解析

host www.baidu.com

nslookup查看主机对应的dns

[root@localhost ~]# nslookup
> server
Default server: 172.17.12.10
Address: 172.17.12.10#53
> www.baidu.com
Server:         172.17.12.10
Address:        172.17.12.10#53

Non-authoritative answer:
www.baidu.com   canonical name = www.a.shifen.com.
Name:   www.a.shifen.com
Address: 61.135.169.121
Name:   www.a.shifen.com
Address: 61.135.169.125
>

修改ip地址和子网掩码

ifconfig eth0 1.1.1.1 netmask 255.0.0.0

禁用/启动 网卡

ifdown/ifup eth0

 

原文地址:https://www.cnblogs.com/yimiao/p/3961247.html