linux 下网关MAC的查看和配置arp命令

linux 下网关MAC的查看和配置arp命令
 
[root@localhost ~]# arp
Address                  HWtype  HWaddress           Flags Mask            Iface
203.171.xx.xx           ether   00:D0:D3:3B:23:A8   C                     eth0
203.171.xx.ab          ether   00:16:76:74:45:A1   C                     eth0
203.171.xx.ac           ether   00:16:76:74:45:A1   C                     eth1
[root@localhost ~]# arp -a
? (203.171.xx.xx) at 00:D0:D3:3B:23:A8 [ether] . eth0
? (203.171.xx.ab) at 00:16:76:74:45:A1 [ether] . eth0
? (203.171.xx.ac) at 00:16:76:74:45:A1 [ether] . eth1
[root@localhost ~]# arp -h
Usage:
  arp [-vn]  [<HW>] [-i <if>] [-a] [<hostname>]             <-Display ARP cache
  arp [-v]          [-i <if>] -d  <hostname> [pub][nopub]    <-Delete ARP entry
  arp [-vnD] [<HW>] [-i <if>] -f  [<filename>]              <-Add entry from file
  arp [-v]   [<HW>] [-i <if>] -s  <hostname> <hwaddr> [temp][nopub] <-Add entry
  arp [-v]   [<HW>] [-i <if>] -s  <hostname> <hwaddr> [netmask <nm>] pub  <-''-
  arp [-v]   [<HW>] [-i <if>] -Ds <hostname> <if> [netmask <nm>] pub      <-''-
        -a                       display (all) hosts in alternative (BSD) style
        -e                       display (all) hosts in default (Linux) style
        -s, --set                set a new ARP entry
        -d, --delete             delete a specified entry
        -v, --verbose            be verbose
        -n, --numeric            don't resolve names
        -i, --device             specify network interface (e.g. eth0)
        -D, --use-device         read <hwaddr> from given device
        -A, -p, --protocol       specify protocol family
        -f, --file               read new entries from file or from /etc/ethers
  <HW>=Use '-H <hw>' to specify hardware address type. Default: ether
  List of possible hardware types (which support ARP):
    strip (Metricom Starmode IP) ash (Ash) ether (Ethernet) 
    tr (16/4 Mbps Token Ring) tr (16/4 Mbps Token Ring (New)) ax25 (AMPR AX.25) 
    netrom (AMPR NET/ROM) rose (AMPR ROSE) arcnet (ARCnet) 
    dlci (Frame Relay DLCI) fddi (Fiber Distributed Data Interface) hippi (HIPPI) 
    irda (IrLAP) x25 (generic X.25) infiniband (InfiniBand) 
[root@localhost ~]# cat /etc/ethers
cat: /etc/ethers: No such file or directory
 
 
添加静态项。这个很有用,特别是局域网中中了arp病毒以后
#arp -s 123.123.123.111 00:11:56:6F:87:D3 
#arp -a                                  .... 显示 ARP 表。
但是arp -s 设置的静态项在用户登出之后或重起之后会失效,如果想要任何时候都不失效,可以将ip和
mac的对应关系写入arp命令默认的配置文件/etc/ethers中
例如:
# vi /etc/ethers 
 arp -s 123.123.123.111 00:11:56:6F:87:D3 


#arp -f /etc/ethers 
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值