Home | 简体中文 | 繁体中文 | 杂文 | Search | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 作品与服务 | Email

第 14 章 Linux IP And Router

目录

14.1. netmask
14.1.1. iptab
14.1.2. netmask - a netmask generation and conversion program
14.2. arp - manipulate the system ARP cache
14.2.1. display hosts
14.2.2. delete a specified entry
14.2.3. /proc/net/arp
14.2.4. /etc/ethers
14.3. iproute2
14.3.1. 添加路由
14.3.2. 删除路由
14.3.3. 变更路由
14.3.4. 替换已有的路由
14.3.5. 增加默认路由
14.3.6. cache
14.4. 策略路由
14.5. 负载均衡
14.6. MASQUERADE
14.7. ip tunnel
14.8. VLAN
14.9. Zebra

14.1. netmask

14.1.1. iptab

# iptab
+----------------------------------------------+
| addrs   bits   pref   class  mask            |
+----------------------------------------------+
|     1      0    /32          255.255.255.255 |
|     2      1    /31          255.255.255.254 |
|     4      2    /30          255.255.255.252 |
|     8      3    /29          255.255.255.248 |
|    16      4    /28          255.255.255.240 |
|    32      5    /27          255.255.255.224 |
|    64      6    /26          255.255.255.192 |
|   128      7    /25          255.255.255.128 |
|   256      8    /24      1C  255.255.255.0   |
|   512      9    /23      2C  255.255.254.0   |
|    1K     10    /22      4C  255.255.252.0   |
|    2K     11    /21      8C  255.255.248.0   |
|    4K     12    /20     16C  255.255.240.0   |
|    8K     13    /19     32C  255.255.224.0   |
|   16K     14    /18     64C  255.255.192.0   |
|   32K     15    /17    128C  255.255.128.0   |
|   64K     16    /16      1B  255.255.0.0     |
|  128K     17    /15      2B  255.254.0.0     |
|  256K     18    /14      4B  255.252.0.0     |
|  512K     19    /13      8B  255.248.0.0     |
|    1M     20    /12     16B  255.240.0.0     |
|    2M     21    /11     32B  255.224.0.0     |
|    4M     22    /10     64B  255.192.0.0     |
|    8M     23     /9    128B  255.128.0.0     |
|   16M     24     /8      1A  255.0.0.0       |
|   32M     25     /7      2A  254.0.0.0       |
|   64M     26     /6      4A  252.0.0.0       |
|  128M     27     /5      8A  248.0.0.0       |
|  256M     28     /4     16A  240.0.0.0       |
|  512M     29     /3     32A  224.0.0.0       |
| 1024M     30     /2     64A  192.0.0.0       |
| 2048M     31     /1    128A  128.0.0.0       |
| 4096M     32     /0    256A  0.0.0.0         |
+----------------------------------------------+
			

14.1.2. netmask - a netmask generation and conversion program

$ sudo apt-get install netmask
			

-s, --standard Output address/netmask pairs

$ netmask -s 192.168.1.0/28
    192.168.1.0/255.255.255.240

$ netmask -s 192.168.1.0/24
    192.168.1.0/255.255.255.0  

$ netmask -s 192.168.1.0/24
    192.168.1.0/255.255.255.0  

$ netmask -s 192.168.1.0/26
    192.168.1.0/255.255.255.192
			

-c, --cidr Output CIDR format address lists

$ netmask -c 192.168.1.0/255.255.255.252
    192.168.1.0/30

$ netmask -c 192.168.1.0/255.255.255.192
    192.168.1.0/26

$ netmask -c 192.168.1.0/255.255.255.240
    192.168.1.0/28
			

-i, --cisco Output Cisco style address lists 思科风格的反子网掩码计算

$ netmask  -i 192.168.1.0/255.255.255.0
    192.168.1.0 0.0.0.255      

$ netmask  -i 192.168.1.0/255.255.255.252
    192.168.1.0 0.0.0.3        

$ netmask  -i 192.168.1.0/24
    192.168.1.0 0.0.0.255      

$ netmask  -i 192.168.1.0/28
    192.168.1.0 0.0.0.15  
			

-r, --range Output ip address ranges 输出地址范围

$ netmask  -r 192.168.1.0/255.255.255.0
    192.168.1.0-192.168.1.255   (256)

$ netmask  -r 192.168.1.0/255.255.255.192
    192.168.1.0-192.168.1.63    (64)
    
$ netmask  -r 192.168.1.0/255.255.255.252
    192.168.1.0-192.168.1.3     (4)
    
$ netmask  -r 192.168.1.0/28
    192.168.1.0-192.168.1.15    (16)
    
$ netmask  -r 192.168.1.0/24
    192.168.1.0-192.168.1.255   (256)
			

$ netmask -r 192.168.1.0/255.255.255.252
    192.168.1.0-192.168.1.3     (4)

$ netmask -r 192.168.1.2/255.255.255.252
    192.168.1.0-192.168.1.3     (4)

$ netmask -r 192.168.1.6/255.255.255.252
    192.168.1.4-192.168.1.7     (4)

$ netmask -r 192.168.1.12/255.255.255.252
   192.168.1.12-192.168.1.15    (4)

$ netmask -r 192.168.1.13/255.255.255.252
   192.168.1.12-192.168.1.15    (4)

$ netmask -r 192.168.1.100/255.255.255.252
  192.168.1.100-192.168.1.103   (4)

$ netmask -r 192.168.1.100/255.255.255.240
   192.168.1.96-192.168.1.111   (16)

$ netmask -r 192.168.1.50/255.255.255.240
   192.168.1.48-192.168.1.63    (16)			
			

-b, --binary Output address/netmask pairs in binary 二进制

$ netmask -b 192.168.1.0/255.255.255.240
11000000 10101000 00000001 00000000 / 11111111 11111111 11111111 11110000

$ netmask -b 172.16.0.0/255.255.252.0
10101100 00010000 00000000 00000000 / 11111111 11111111 11111100 00000000
			
			
comments powered by Disqus