centos7.6批量增加修改删除虚拟网卡操作介绍

1确认内核是否有tun模块modinfotunmodprobetunlsmod|greptun2安装tunctl软件yuminstalltunctl-yvim/etc/yum.r...

1 确认内核是否有tun模块


modinfo tun

modprobe tun
lsmod | grep tun


21 netmask 255.255.255.0 promisc ifconfig tap5 192.168.130.23 netmask 255.255.255.0 promisc ifconfig tap6 192.168.130.24 netmask 255.255.255.0 promisc ifconfig tap7 192.168.130.25 netmask 255.255.255.0 promisc ifconfig tap8 192.168.130.28 netmask 255.255.255.0 promisc ifconfig tap9 192.168.130.30 netmask 255.255.255.0 promisc

show ifconfig br-zhai 192.168.9.1 up ifconfig br-zhai ifconfig -a brctl show brctl showmacs br-zhai ifconfig tap0 promisc ifconfig

开启自动启动虚拟网卡脚本


vim /etc/init.d/config_tap 

  #!/bin/bash
  #
  # config_tap          Start up the tun/tap virtual nic
  #
  # chkconfig: 2345 55 25
  USER="root"
  TAP_NETWORK="192.168.130.10"
  TAP_DEV_NUM=0
  DESC="TAP config"
  do_start() {
    if [ ! -x /usr/sbin/tunctl ]; then
      echo "/usr/sbin/tunctl was NOT found!"
      exit 1
    fi
    tunctl -t tap$TAP_DEV_NUM -u root
    ifconfig tap$TAP_DEV_NUM ${TAP_NETWORK}  netmask 255.255.255.0 promisc
    ifconfig tap$TAP_DEV_NUM
  }
  do_stop() {
    ifconfig tap$TAP_DEV_NUM down 
  }
  do_restart() {
    do_stop
    do_start
  }
  check_status() {
    ifconfig tap$TAP_DEV_NUM 
  }
  case $1 in 
    start)    do_start;;
    stop)     do_stop;;
    restart)  do_restart;;
    status)
              echo "Status of $DESC: "
              check_status
              exit "$?"
              ;;
    *)
      echo "Usage: $0 {start|stop|restart|status}"
      exit 1 
  esac
n=0
while [ $n -le 8 ];do
n=$(( $n + 1 ))
ip tuntap add tap$n mode tap
done
echo $i 
ifconfig tap0 192.168.1.110  netmask 255.255.255.0 promisc 
ifconfig tap1 192.168.1.111  netmask 255.255.255.0 promisc 
ifconfig tap2 192.168.1.112  netmask 255.255.255.0 promisc 
ifconfig tap3 192.168.1.113  netmask 255.255.255.0 promisc 
ifconfig tap4 192.168.1.114  netmask 255.255.255.0 promisc 
ifconfig tap5 192.168.1.115  netmask 255.255.255.0 promisc 
ifconfig tap6 192.168.1.116  netmask 255.255.255.0 promisc 
ifconfig tap7 192.168.1.117  netmask 255.255.255.0 promisc 
ifconfig tap8 192.168.1.118  netmask 255.255.255.0 promisc 
ifconfig tap9 192.168.1.119  netmask 255.255.255.0 promisc 

chkconfig --add config_tap 
chkconfig --level 345 config_tap on
service config_tap start 

到此这篇关于centos7.6批量增加修改删除虚拟网卡操作介绍的文章就介绍到这了,更多相关centos7.6增加修改删除网卡内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐