zoukankan      html  css  js  c++  java
  • ubuntu下双网卡桥接

    1. 安装 brctl工具
    sudo apt-get install bridge-utils
    2. 添加桥
    # brctl addbr br0 #创建桥接 br0
    # brctl addif br0 eth0 eth1 #添加 eth0, eth1 到 br0
    # ifconfig br0 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255 up
    3. 打开ip转发
    sudo vim /etc/sysctl.conf
    net.ipv4.ip_forward=1
    去掉该行前面的注释符#
    sudo sysctl -p /etc/sysctl.conf
    文件立即生效
     
    3. 修改配置
    vim /etc/network/interfaces
    auto lo br0
    iface lo inet loopback
    auto eth0
    iface eth0 inet manual
    auto eth1
    iface eth1 inet manual
    iface br0 inet dhcp
    bridge_ports eth0 eth1
     
    或者使用静态IP
     
    iface br0 inet static
    bridge_ports eth0 eth1
    address 192.168.1.2
    broadcast 192.168.1.255
    netmask 255.255.255.0
    gateway 192.168.1.1
     
    4. 重启机器
     
    实例配置:
     

    root@weifeng-ThinkPad-E470:~# cat /etc/network/interfaces
    # interfaces(5) file used by ifup(8) and ifdown(8)
    auto lo br0
    iface lo inet loopback
    auto enp4s0
    iface enp4s0 inet manual
    auto enx000ec6d22489
    iface enx000ec6d22489 inet manual
    iface br0 inet static
    bridge_ports enp4s0 enx000ec6d22489
    address 192.168.4.147
    broadcast 192.168.4.255
    netmask 255.255.255.0
    gateway 192.168.4.1
    dns-nameservers 114.114.114.114

    root@weifeng-ThinkPad-E470:~# ifconfig
    br0 Link encap:以太网 硬件地址 00:0e:c6:d2:24:89
    inet 地址:192.168.4.147 广播:192.168.4.255 掩码:255.255.255.0
    inet6 地址: fe80::20e:c6ff:fed2:2489/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 跃点数:1
    接收数据包:26213 错误:0 丢弃:0 过载:0 帧数:0
    发送数据包:13242 错误:0 丢弃:0 过载:0 载波:0
    碰撞:0 发送队列长度:1000
    接收字节:33057941 (33.0 MB) 发送字节:1009375 (1.0 MB)

    enp4s0 Link encap:以太网 硬件地址 c8:5b:76:96:54:8d
    UP BROADCAST RUNNING MULTICAST MTU:1500 跃点数:1
    接收数据包:47984 错误:0 丢弃:2 过载:0 帧数:0
    发送数据包:14024 错误:0 丢弃:47 过载:0 载波:0
    碰撞:0 发送队列长度:1000
    接收字节:35367800 (35.3 MB) 发送字节:1116775 (1.1 MB)

    enx000ec6d22489 Link encap:以太网 硬件地址 00:0e:c6:d2:24:89
    UP BROADCAST MULTICAST MTU:1500 跃点数:1
    接收数据包:0 错误:0 丢弃:0 过载:0 帧数:0
    发送数据包:0 错误:0 丢弃:0 过载:0 载波:0
    碰撞:0 发送队列长度:1000
    接收字节:0 (0.0 B) 发送字节:0 (0.0 B)

     
  • 相关阅读:
    深入理解TCP协议及其源代码
    Socket与系统调用深度分析
    构建调试Linux内核网络代码的环境MenuOS系统
    创新产品的需求分析:未来的图书会是什么样子?
    socket通信的原理与实践
    案例分析:设计模式与代码的结构特性
    网络相关的命令工具研究报告:ssh
    业务领域建模Domain Modeling
    ubuntu 设置静态ip,但显示scope global secondary ens33
    解决Python查询Mysql中文乱码问题
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/7614461.html
Copyright © 2011-2022 走看看