linux新建/删除子接口

  1. 安装vconfig
    apt-get install vconfig
  2. 运行802.1q模块
    modprobe 8021q
  3. 新建接口vlan
    vconfig add eth2 3021
  4. 配置子接口
    ifconfig eth2.3021 18.5.82.53 netmask 255.255.255.0
  5. 查看接口ifconfig
    eth2.3021 Link encap:Ethernet HWaddr 00:0b?f3:36:78
    inet addr:18.5.82.53 Bcast:18.5.82.255 Mask:255.255.255.0
    inet6 addr: fe80::20b:abff:fef3:3678/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:0 (0.0 B) TX bytes:5440 (5.4 KB)
  6. 子接口down
    ifconfig eth2.3020 down
  7. 接口down后ifconfig查不到子接口,ip add可以看到
    10: eth2.3020@eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
    link/ether 00:0b?f3:36:78 brd ff:ff:ff:ff:ff:ff
  8. 彻底删除子接口
    ip link delete eth2.3020
    这都是临时生效,重启后失效,要永久生效需要修改配置文件
    /etc/network/interfaces

猜你喜欢

转载自blog.csdn.net/ly_6118/article/details/96838237