zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Go语言程序调试
    IDA FLIRT使用
    通过PEB寻找函数地址
    使用IWebBrowser2操控浏览器页面测试(IE)
    虚拟机检测手段
    初步了解PE分析
    CG-CTF simple-machine
    调试器原理初步学习
    简单shellcode编写
    使用ReportViewer的远程模式
  • 原文地址:https://www.cnblogs.com/gavinwu/p/3471570.html
Copyright © 2011-2022 走看看