zoukankan      html  css  js  c++  java
  • tunctl添加虚拟网卡TUN/TAP与brctl添加网桥


    http://blog.csdn.net/zhaihaifei/article/details/23168621


    1 Linux添加虚拟网卡三种方法

    方法1: ifconfig命令创建删除虚拟网卡

    1. ifconfig eth0:0 192.168.1.10 netmask 255.255.255.0 up  
    删除虚拟网卡:
    1. ifconfig eth0:0 down  
    重启服务器或者网络后,虚拟网卡就失效. 注意:添加的虚拟网卡和原网卡物理地址是一样的。

    方法2: 修改网卡配置文件

    在ubuntu下,修改网卡的配置文件/etc/network/interfaces:
    1. cat /etc/network/interfaces  
    2. auto eth0  
    3. iface eth0 inet dhcp  
    4. auto eth0:1  
    5. iface eth0:1 inet static  
    6.         address 192.168.11.1  
    7.         netmask 255.255.255.0  
    8.         gateway 192.168.11.1  
    9. auto eth0:2  
    10. iface eth0:2 inet static  
    11.         address 192.168.12.1  
    12.         netmask 255.255.255.0  
    13.         gateway 192.168.12.1  
    保存后,重新加载配置文件才会生效,使用如下命令重启网卡:
    1. service networking restart  
    优点: 重启服务器或者网卡配置不会丢失。

    RHEL系统中,网卡IP配置的文件在/etc/sysconfig/network-scripts/下,文件分别为ehtx或ethx:x,执行命令如下:
    1. #cd /etc/sysconfig/network-scripts/    
    2. #cp ifcfg-eth0 ifcfg-eth0:1    
    3. #vi ifcfg-eth0:1    
    4. DEVICE=eth0    
    5. BOOTPROTO=none    
    6. HWADDR=00:19:D1:24:2A:EC    
    7. ONBOOT=yes    
    8. DHCP_HOSTNAME=zhongqg.localdomain    
    9. IPADDR=192.168.1.55    
    10. NETMASK=255.255.252.0    
    11. GATEWAY=192.168.0.1    
    12. TYPE=Ethernet    
    13. USERCTL=no    
    14. IPV6INIT=no    
    15. PEERDNS=yes    
        修改其中的IPADDR部分为192.168.1.57,然后保存退出并启动该配置文件!
    1. #ifup eth0:1    

    方法3:创建tap

    前两种方法都有一个特点,创建的网卡可有不同的ip地址,但是Mac地址相同,无法用来创建虚拟机。
    使用命令tunctl添加虚拟网卡tap。

    2 tunctl安装与使用

    2.1 安装apt-get install uml-utilities

    1. root@host:~# tunctl  
    2. The program 'tunctl' is currently not installed. You can install it by typing:  
    3. apt-get install uml-utilities  
    4. root@host:~# apt-get install uml-utilities  
    5. Reading package lists... Done  
    6. Building dependency tree  
    7. Reading state information... Done  
    8. Suggested packages:  
    9.   user-mode-linux  
    10. The following NEW packages will be installed:  
    11.   uml-utilities  
    12. 0 upgraded, 1 newly installed, 0 to remove and 105 not upgraded.  
    13. Need to get 61.9 kB of archives.  
    14. After this operation, 267 kB of additional disk space will be used.  
    15. Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/universe uml-utilities amd64 20070815-1.3ubuntu1 [61.9 kB]  
    16. Fetched 61.9 kB in 2s (27.7 kB/s)  
    17. Selecting previously unselected package uml-utilities.  
    18. (Reading database ... 60223 files and directories currently installed.)  
    19. Preparing to unpack .../uml-utilities_20070815-1.3ubuntu1_amd64.deb ...  
    20. Unpacking uml-utilities (20070815-1.3ubuntu1) ...  
    21. Processing triggers for ureadahead (0.100.0-16) ...  
    22. ureadahead will be reprofiled on next reboot  
    23. Processing triggers for man-db (2.6.7.1-1ubuntu1) ...  
    24. Setting up uml-utilities (20070815-1.3ubuntu1) ...  
    25.  * Starting User-mode networking switch uml_switch                                                                         [ OK ]  
    26. Processing triggers for ureadahead (0.100.0-16) ...  

    2.2 使用tunctl

    NAME
           tunctl — create and manage persistent TUN/TAP interfaces
    SYNOPSIS
           tunctl [-f tun-clone-device]  [-u owner]  [-t device-name]
           tunctl [-f tun-clone-device]  -d device-name
    DESCRIPTION
           This manual page documents briefly the tunctl command.
           This  manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual
           page.  Instead, it has documentation in HTML format; see below.
           tunctl allows the host sysadmin to preconfigure a TUN/TAP device for use by a particular user. That user may open  and
           use the device, but may not change any aspects of the host side of the interface.
    USAGE
           To create an interface for use by a particular user, invoke tunctl without the -d option:
           tunctl -u someuser       #Set 'tap0' persistent and owned by 'someuser'
           Then, configure the interface as normal:
           ifconfig tap0 192.168.0.254 up
           route add -host 192.168.0.253 dev tap0
           bash -c 'echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp'
           arp -Ds 192.168.0.253 eth0 pub

           To delete the interface, use the -d option:
           tunctl -d tap0    #Set 'tap0' nonpersistent

    3 TUN/TAP

        tun/tap 驱动程序实现了虚拟网卡的功能,tun表示虚拟的是点对点设备,tap表示虚拟的是以太网设备,这两种设备针对网络包实施不同的封装。 利用tun/tap 驱动,可以将tcp/ip协议栈处理好的网络分包传给任何一个使用tun/tap驱动的进程,由进程重新处理后再发到物理链路中。 

    3.1 Tun/Tap驱动程序工作原理

        做为虚拟网卡驱动,Tun/Tap驱动程序的数据接收和发送并不直接和真实网卡打交道, 而是在Linux内核中添加了一个TUN/TAP虚拟网络设备的驱动程序和一个与之相关连的字符设备 /dev/net/tun,字符设备tun作为用户空间和内核空间交换数据的接口。
        当内核将数据包发送到虚拟网络设备时,数据包被保存在设备相关的一个队 列中,直到用户空间程序通过打开的字符设备tun的描述符读取时,它才会被拷贝到用户空间的缓冲区中,其效果就相当于,数据包直接发送到了用户空间。通过 系统调用write发送数据包时其原理与此类似。
        在linux下,要实现 内核空间 和 用户空间 数据的交互,有多种方式:可以通用socket创建特殊套接字,利用套接字实现数据交互;通过proc文件系统创建文件来进行数据交互;还可以使用设备文件的方式,访问设备文件会调用设备驱动相应的例程,设备驱动本身就是 内核空间 和 用户空间 的一个接口,Tun/tap驱动就是利用设备文件实现 用户空间 和 内核空间 的数据交互

        从结构上来说,Tun/tap驱动并不单纯是实现网卡驱动,同时它还实现了字符设备驱动部分。以字符设备的方式连接用户空间和内核空间。
        Tun/tap 驱动程序中包含两个部分,一部分是字符设备驱动,还有一部分是网卡驱动部分。利用网卡驱动部分接收来自TCP/IP协议栈的网络分包并发送或者反过来将接收到的网络分包传给协议栈处理,而字符驱动部分则将网络分包在 用户空间和内核空间 之间传送,模拟物理链路的数据接收和发送。Tun/tap驱动很好的实现了两种驱动的结合。
        

    3.2 设置    

    3.2.1 确认内核是否支持tun/tap

    确认内核是否有tun模块
    1. [root@hunterfu]# modinfo tun  
    2. filename:       /lib/modules/2.6.34.7-56.fc13.i686.PAE/kernel/drivers/net/tun.ko  
    3. alias:          char-major-10-200  
    4. license:        GPL  
    5. author:         (C) 1999-2004 Max Krasnyansky <maxk@qualcomm.com>  
    6. description:    Universal TUN/TAP device driver  
    7. srcversion:     880DE258930FE60D765B735  
    8. depends:          
    9. vermagic:       2.6.34.7-56.fc13.i686.PAE SMP mod_unload 686   

    加载内核模块
    1. [root@hunterfu ~]#  modprobe tun  
    2. [root@hunterfu ~]# lsmod | grep tun  
    3. tun                    10548  1   
    执行以上命令后,出现如上输出,说明模块加载成功

    3.2.2 创建和配置虚拟网卡

    确认是否有tunctl命令,如果没有通过yum安装即可
    apt-get install uml-utilities 或 yum install tunctl
    创建虚拟网卡设备
    tunctl -t tap0 -u root
    设置虚拟网卡
    ifconfig tap0 192.168.0.1  netmask 255.255.255.0 promisc
    经过如上操作后,虚拟网卡已经建立和配置好了。

    3.2.3 作为系统服务随系统自动启动创建虚拟网卡

    编写配置脚本(符合chkconfig规范)
     
    1. [root@hunterfu ~]# cat /etc/init.d/config_tap   
    2.   #!/bin/bash  
    3.   #  
    4.   # config_tap          Start up the tun/tap virtual nic  
    5.   #  
    6.   # chkconfig: 2345 55 25  
    7.     
    8.   USER="root"  
    9.   TAP_NETWORK="192.168.0.1"  
    10.   TAP_DEV_NUM=0  
    11.   DESC="TAP config"  
    12.     
    13.   do_start() {  
    14.     if [ ! -x /usr/sbin/tunctl ]; then  
    15.       echo "/usr/sbin/tunctl was NOT found!"  
    16.       exit 1  
    17.     fi  
    18.     tunctl -t tap$TAP_DEV_NUM -u root  
    19.     ifconfig tap$TAP_DEV_NUM ${TAP_NETWORK}  netmask 255.255.255.0 promisc  
    20.     ifconfig tap$TAP_DEV_NUM  
    21.   }  
    22.     
    23.   do_stop() {  
    24.     ifconfig tap$TAP_DEV_NUM down   
    25.   }  
    26.   do_restart() {  
    27.     do_stop  
    28.     do_start  
    29.   }  
    30.   check_status() {  
    31.     ifconfig tap$TAP_DEV_NUM   
    32.   }  
    33.     
    34.   case $1 in   
    35.     start)    do_start;;  
    36.     stop)     do_stop;;  
    37.     restart)  do_restart;;  
    38.     status)  
    39.               echo "Status of $DESC: "  
    40.               check_status  
    41.               exit "$?"  
    42.               ;;  
    43.     *)  
    44.     echo "Usage: $0 {start|stop|restart|status}"  
    45.     exit 1   
    46.   esac  

    可以根据具体需求修改此脚本
    加入到系统服务中
    1. [root@hunterfu ~]# chkconfig --add config_tap   
    2. [root@hunterfu ~]# chkconfig --level 345 config_tap on  
    操作完成后,就可以像其他标准服务一样,通过 service config_tap start 来进行创建和启动操作    

    4 tunctl添加tap并用brctl添加到网桥

    1. root@host# ifconfig -a  
    2. eth0      Link encap:Ethernet  HWaddr fa:16:3e:7b:4e:e1  
    3.           inet addr:192.168.33.24  Bcast:192.168.47.255  Mask:255.255.240.0  
    4.           inet6 addr: fe80::f816:3eff:fe7b:4ee1/64 Scope:Link  
    5.           UP BROADCAST RUNNING MULTICAST  MTU:1454  Metric:1  
    6.           RX packets:5922 errors:0 dropped:0 overruns:0 frame:0  
    7.           TX packets:2002 errors:0 dropped:0 overruns:0 carrier:0  
    8.           collisions:0 txqueuelen:1000  
    9.           RX bytes:503405 (503.4 KB)  TX bytes:322612 (322.6 KB)  
    10.   
    11.   
    12. lo        Link encap:Local Loopback  
    13.           inet addr:127.0.0.1  Mask:255.0.0.0  
    14.           inet6 addr: ::1/128 Scope:Host  
    15.           UP LOOPBACK RUNNING  MTU:65536  Metric:1  
    16.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    17.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    18.           collisions:0 txqueuelen:0  
    19.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    20.   
    21.   
    22. root@host# tunctl  
    23. Set 'tap0' persistent and owned by uid 0  
    24. root@host# ifconfig -a  
    25. eth0      Link encap:Ethernet  HWaddr fa:16:3e:7b:4e:e1  
    26.           inet addr:192.168.33.24  Bcast:192.168.47.255  Mask:255.255.240.0  
    27.           inet6 addr: fe80::f816:3eff:fe7b:4ee1/64 Scope:Link  
    28.           UP BROADCAST RUNNING MULTICAST  MTU:1454  Metric:1  
    29.           RX packets:6089 errors:0 dropped:0 overruns:0 frame:0  
    30.           TX packets:2057 errors:0 dropped:0 overruns:0 carrier:0  
    31.           collisions:0 txqueuelen:1000  
    32.           RX bytes:514735 (514.7 KB)  TX bytes:339978 (339.9 KB)  
    33.   
    34.   
    35. lo        Link encap:Local Loopback  
    36.           inet addr:127.0.0.1  Mask:255.0.0.0  
    37.           inet6 addr: ::1/128 Scope:Host  
    38.           UP LOOPBACK RUNNING  MTU:65536  Metric:1  
    39.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    40.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    41.           collisions:0 txqueuelen:0  
    42.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    43.   
    44.   
    45. tap0      Link encap:Ethernet  HWaddr 7e:13:f1:29:c0:ed  
    46.           BROADCAST MULTICAST  MTU:1500  Metric:1  
    47.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    48.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    49.           collisions:0 txqueuelen:500  
    50.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    51.   
    52.   
    53. root@host# tunctl  
    54. Set 'tap1' persistent and owned by uid 0  
    55. root@host# ifconfig -a  
    56. eth0      Link encap:Ethernet  HWaddr fa:16:3e:7b:4e:e1  
    57.           inet addr:192.168.33.24  Bcast:192.168.47.255  Mask:255.255.240.0  
    58.           inet6 addr: fe80::f816:3eff:fe7b:4ee1/64 Scope:Link  
    59.           UP BROADCAST RUNNING MULTICAST  MTU:1454  Metric:1  
    60.           RX packets:6323 errors:0 dropped:0 overruns:0 frame:0  
    61.           TX packets:2116 errors:0 dropped:0 overruns:0 carrier:0  
    62.           collisions:0 txqueuelen:1000  
    63.           RX bytes:530988 (530.9 KB)  TX bytes:347960 (347.9 KB)  
    64.   
    65.   
    66. lo        Link encap:Local Loopback  
    67.           inet addr:127.0.0.1  Mask:255.0.0.0  
    68.           inet6 addr: ::1/128 Scope:Host  
    69.           UP LOOPBACK RUNNING  MTU:65536  Metric:1  
    70.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    71.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    72.           collisions:0 txqueuelen:0  
    73.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    74.   
    75.   
    76. tap0      Link encap:Ethernet  HWaddr 7e:13:f1:29:c0:ed  
    77.           BROADCAST MULTICAST  MTU:1500  Metric:1  
    78.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    79.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    80.           collisions:0 txqueuelen:500  
    81.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    82.   
    83.   
    84. tap1      Link encap:Ethernet  HWaddr 7e:6a:fc:31:18:35  
    85.           BROADCAST MULTICAST  MTU:1500  Metric:1  
    86.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    87.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    88.           collisions:0 txqueuelen:500  
    89.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    90.   
    91.   
    92. root@host# brctl show  
    93. bridge name     bridge id               STP enabled     interfaces  
    94. root@host# ifconfig tap0 0.0.0.0  
    95. root@host# ifconfig tap1 0.0.0.0  
    96. root@host# ifconfig -a  
    97. eth0      Link encap:Ethernet  HWaddr fa:16:3e:7b:4e:e1  
    98.           inet addr:192.168.33.24  Bcast:192.168.47.255  Mask:255.255.240.0  
    99.           inet6 addr: fe80::f816:3eff:fe7b:4ee1/64 Scope:Link  
    100.           UP BROADCAST RUNNING MULTICAST  MTU:1454  Metric:1  
    101.           RX packets:7246 errors:0 dropped:0 overruns:0 frame:0  
    102.           TX packets:2525 errors:0 dropped:0 overruns:0 carrier:0  
    103.           collisions:0 txqueuelen:1000  
    104.           RX bytes:595705 (595.7 KB)  TX bytes:545518 (545.5 KB)  
    105.   
    106.   
    107. lo        Link encap:Local Loopback  
    108.           inet addr:127.0.0.1  Mask:255.0.0.0  
    109.           inet6 addr: ::1/128 Scope:Host  
    110.           UP LOOPBACK RUNNING  MTU:65536  Metric:1  
    111.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    112.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    113.           collisions:0 txqueuelen:0  
    114.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    115.   
    116.   
    117. tap0      Link encap:Ethernet  HWaddr 7e:13:f1:29:c0:ed  
    118.           UP BROADCAST MULTICAST  MTU:1500  Metric:1  
    119.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    120.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    121.           collisions:0 txqueuelen:500  
    122.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    123.   
    124.   
    125. tap1      Link encap:Ethernet  HWaddr 7e:6a:fc:31:18:35  
    126.           UP BROADCAST MULTICAST  MTU:1500  Metric:1  
    127.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    128.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    129.           collisions:0 txqueuelen:500  
    130.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    131.   
    132.   
    133. root@host# brctl addbr br-zhai  
    134. root@host# brctl addif br-zhai tap0  
    135. root@host# brctl addif br-zhai tap1  
    136. root@host# ifconfig -a  
    137. br-zhai   Link encap:Ethernet  HWaddr 7e:13:f1:29:c0:ed  
    138.           BROADCAST MULTICAST  MTU:1500  Metric:1  
    139.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    140.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    141.           collisions:0 txqueuelen:0  
    142.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    143.   
    144.   
    145. eth0      Link encap:Ethernet  HWaddr fa:16:3e:7b:4e:e1  
    146.           inet addr:192.168.33.24  Bcast:192.168.47.255  Mask:255.255.240.0  
    147.           inet6 addr: fe80::f816:3eff:fe7b:4ee1/64 Scope:Link  
    148.           UP BROADCAST RUNNING MULTICAST  MTU:1454  Metric:1  
    149.           RX packets:7515 errors:0 dropped:0 overruns:0 frame:0  
    150.           TX packets:2616 errors:0 dropped:0 overruns:0 carrier:0  
    151.           collisions:0 txqueuelen:1000  
    152.           RX bytes:615539 (615.5 KB)  TX bytes:561216 (561.2 KB)  
    153.   
    154.   
    155. lo        Link encap:Local Loopback  
    156.           inet addr:127.0.0.1  Mask:255.0.0.0  
    157.           inet6 addr: ::1/128 Scope:Host  
    158.           UP LOOPBACK RUNNING  MTU:65536  Metric:1  
    159.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    160.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    161.           collisions:0 txqueuelen:0  
    162.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    163.   
    164.   
    165. tap0      Link encap:Ethernet  HWaddr 7e:13:f1:29:c0:ed  
    166.           UP BROADCAST MULTICAST  MTU:1500  Metric:1  
    167.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    168.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    169.           collisions:0 txqueuelen:500  
    170.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    171.   
    172.   
    173. tap1      Link encap:Ethernet  HWaddr 7e:6a:fc:31:18:35  
    174.           UP BROADCAST MULTICAST  MTU:1500  Metric:1  
    175.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    176.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    177.           collisions:0 txqueuelen:500  
    178.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    179.   
    180.   
    181. root@host# brctl show  
    182. bridge name     bridge id               STP enabled     interfaces  
    183. br-zhai         8000.7e13f129c0ed       no              tap0  
    184.                                                         tap1  
    185. root@host# ifconfig br-zhai 192.168.9.1 up  
    186. root@host# ifconfig br-zhai  
    187. br-zhai   Link encap:Ethernet  HWaddr 7e:13:f1:29:c0:ed  
    188.           inet addr:192.168.9.1  Bcast:192.168.9.255  Mask:255.255.255.0  
    189.           UP BROADCAST MULTICAST  MTU:1500  Metric:1  
    190.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    191.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    192.           collisions:0 txqueuelen:0  
    193.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    194. root@host# brctl showmacs br-zhai  
    195. port no mac addr                is local?       ageing timer  
    196.   1     7e:13:f1:29:c0:ed       yes                0.00  
    197.   2     7e:6a:fc:31:18:35       yes                0.00  
    198. root@host# brctl  
    199. Usage: brctl [commands]  
    200. commands:  
    201.         addbr           <bridge>                add bridge  
    202.         delbr           <bridge>                delete bridge  
    203.         addif           <bridge> <device>       add interface to bridge  
    204.         delif           <bridge> <device>       delete interface from bridge  
    205.         hairpin         <bridge> <port> {on|off}        turn hairpin on/off  
    206.         setageing       <bridge> <time>         set ageing time  
    207.         setbridgeprio   <bridge> <prio>         set bridge priority  
    208.         setfd           <bridge> <time>         set bridge forward delay  
    209.         sethello        <bridge> <time>         set hello time  
    210.         setmaxage       <bridge> <time>         set max message age  
    211.         setpathcost     <bridge> <port> <cost>  set path cost  
    212.         setportprio     <bridge> <port> <prio>  set port priority  
    213.         show            [ <bridge> ]            show a list of bridges  
    214.         showmacs        <bridge>                show a list of mac addrs  
    215.         showstp         <bridge>                show bridge stp info  
    216.         stp             <bridge> {on|off}       turn stp on/off  
    217.             
    218. root@host# ifconfig tap0 promisc  
    219. root@host# ifconfig  
    220. br-zhai   Link encap:Ethernet  HWaddr 7e:13:f1:29:c0:ed  
    221.           inet addr:192.168.9.1  Bcast:192.168.9.255  Mask:255.255.255.0  
    222.           UP BROADCAST MULTICAST  MTU:1500  Metric:1  
    223.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    224.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    225.           collisions:0 txqueuelen:0  
    226.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    227.   
    228.   
    229. eth0      Link encap:Ethernet  HWaddr fa:16:3e:7b:4e:e1  
    230.           inet addr:192.168.33.24  Bcast:192.168.47.255  Mask:255.255.240.0  
    231.           inet6 addr: fe80::f816:3eff:fe7b:4ee1/64 Scope:Link  
    232.           UP BROADCAST RUNNING MULTICAST  MTU:1454  Metric:1  
    233.           RX packets:115463 errors:0 dropped:0 overruns:0 frame:0  
    234.           TX packets:6834 errors:0 dropped:0 overruns:0 carrier:0  
    235.           collisions:0 txqueuelen:1000  
    236.           RX bytes:11942923 (11.9 MB)  TX bytes:1083602 (1.0 MB)  
    237.   
    238.   
    239. lo        Link encap:Local Loopback  
    240.           inet addr:127.0.0.1  Mask:255.0.0.0  
    241.           inet6 addr: ::1/128 Scope:Host  
    242.           UP LOOPBACK RUNNING  MTU:65536  Metric:1  
    243.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    244.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    245.           collisions:0 txqueuelen:0  
    246.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    247.   
    248.   
    249. tap0      Link encap:Ethernet  HWaddr 7e:13:f1:29:c0:ed  
    250.           UP BROADCAST PROMISC MULTICAST  MTU:1500  Metric:1  
    251.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    252.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    253.           collisions:0 txqueuelen:500  
    254.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
    255.   
    256.   
    257. tap1      Link encap:Ethernet  HWaddr 7e:6a:fc:31:18:35  
    258.           UP BROADCAST MULTICAST  MTU:1500  Metric:1  
    259.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
    260.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
    261.           collisions:0 txqueuelen:500  
    262.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  


    参考:
    1 Linux操作系统下Virtual Box的网络设置:http://www.51cto.com/art/200709/56461.htm

    Linux

    多网卡绑定、

    IP

    别名

    2 Linux多网卡绑定、IP别名:https://wenku.baidu.com/view/6a4c0e6f31126edb6f1a10a4.html



  • 相关阅读:
    IOS学习笔记 ---- 15/09/14
    IOS学习笔记 ---- 15/09/07
    IOS学习笔记 ---- 15/09/06
    IOS学习笔记 ---- 15/09/02
    IOS学习笔记 ---- 15/09/01
    IOS学习笔记 ---- 15/08/31
    IOS学习笔记 ---- 15/08/30之前
    ios之UITableViewController(二) tableView的编辑模式
    ios之UIPageController和UIScrollView配合使用
    ios之UIScrollView
  • 原文地址:https://www.cnblogs.com/ztguang/p/12644670.html
Copyright © 2011-2022 走看看