• Ubuntu 将两张网卡的ubuntu配置成路由器


    eth0      Link encap:Ethernet  HWaddr 40:16:9f:f0:fc:10  
              inet addr:192.168.1.18  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::4216:9fff:fef0:fc10/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:637 errors:0 dropped:0 overruns:0 frame:0
              TX packets:591 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:632116 (632.1 KB)  TX bytes:60416 (60.4 KB)

    eth1      Link encap:Ethernet  HWaddr 50:e5:49:14:0d:95  
              inet addr:172.17.64.228  Bcast:172.17.65.255  Mask:255.255.254.0
              inet6 addr: fe80::52e5:49ff:fe14:d95/64 Scope:Link
              inet6 addr: 2001:db8::6ccd:b1a3:c799:25e/64 Scope:Global
              inet6 addr: 2001:db8::52e5:49ff:fe14:d95/64 Scope:Global
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:29201 errors:0 dropped:3488 overruns:0 frame:0
              TX packets:3022 errors:0 dropped:0 overruns:0 carrier:1
              collisions:0 txqueuelen:1000
              RX bytes:4318829 (4.3 MB)  TX bytes:364085 (364.0 KB)

    172.16.100.7, 172.16.100.9, 172.16.100.8, 172.17.198.32

    1.sudo apt-get remove network-manager
       sudo vim /etc/network/interfaces

      auto lo
     iface lo inet loopback
    auto eth1
    iface eth1 inet static
    address 192.168.168.137
    gateway 192.168.168.1
    netmask 255.255.255.0
    dns-nameservers 114.114.114.114

    auto eth1:1
    iface eth1:1 inet static
    address 172.16.184.210
    netmask 255.255.255.0

    auto eth0
    iface eth0 inet static
    address 192.168.1.12
    netmask 255.255.255.0

    auto eth0:1
    iface eth0:1 inet static
    address 192.168.0.1
    netmask 255.255.255.0

    重启,使相关配置生效 sudo /etc/init.d/networing restart

    2. 配置使系统具备路由功能
        sudo vim /etc/sysctl.conf
        net.ipv4.ip_forward=1
        重启配置, 使生效sudo sysctl -p。

    3. 添加NAT条目
       sudo iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth1 -j MASQUERADE
       -s source network
       -o dest netwok card
      
        注, 第三步添加NAT条目的配置在重启后就会消失,应重新添加或写脚本在启动时就添加。

        若要求永久生效, 则按下列步骤。
        sudo vim /etc/init.d/nat
        添加  sudo iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth1 -j MASQUERADE
        sudo chmod 777 /etc/init.d/nat
        sudo ln -s /etc/init.d/nat /etc/rcS.d/S42nat

  • 相关阅读:
    Maven工程运行环境修改
    Maven中出现org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException错误
    IDEA创建maven_web工程后,右键包没有Servlet、Filter、Listener选项
    Spring中的依赖注入
    什么是JavaBean
    mybatis配置SqlMapConfig.xm时没有提示
    JDK1.8之后匿名内部类访问方法中的局部变量不用加final修饰
    架构、框架和设计模式
    CitrixSQL Server 2016高可用之SQL镜像 SQL Server mirror 带见证服务器
    CitrixPVS BDM启动模式创建虚机 BDM模式部署桌面(精华)
  • 原文地址:https://www.cnblogs.com/gavinwu/p/3471570.html
Copyright © 2020-2023  润新知