vyatta: snat, dnat

来源:互联网 发布:linux 启动apache2 编辑:程序博客网 时间:2024/05/29 13:28

http://www.cnblogs.com/SunJavaLiu/articles/2609175.html


用Vyatta6.4配置NAT,VPN,DNS

#为两个网卡配置IP地址

interfaces {

    ethernet eth0 {

        address 50.103.55.99/30     #配置公网网卡IP

        duplex auto

        hw-id 00:00:b4:c0:7f:67

        smp_affinity auto

        speed auto

    }

    ethernet eth1 {

        address 10.1.1.119/25    #配置内网网卡IP

        duplex auto

        hw-id 00:10:b5:48:30:30

        smp_affinity auto

        speed auto

    }

    loopback lo {

    }

}

#做双向NAT ( SNAT DNAT ),  

#  SNAT即 源地址转换(Source Network Address Translation )是将多个私有内部IP转换为指定的IP地址,通俗理解成:单位多个内网电脑通过一个ADSL上网。方向是由内到外

#  DNAT 即 目的地址转换(Destination Network Address Translation)是将公网IP地址映射成内网IP地址,

nat {

    destination {

        rule 1 {

            destination {    #这里是DNAT

                address 50.103.55.99

                port 80

            }

            inbound-interface eth0  #数据传入接口绑定在 eth0

            protocol tcp          #数据协议  这里是TCP,也可是UDP     

            translation {

                address 10.1.1.101   #映射后的IP地址  将50.103.55.9980端口映射                 port 80               成  10.1.1.101 的80端口

#切记注意:因为我这里有多个网关地址,10.1.1.101的网关要指向eth1 (网关地址配置为10.1.1.119)

                                       

            }

        }

}

#SNAT   将网络号为10.1.1.0/25的所有ip转换为50.103.55.99

    source {

        rule 1 {

            outbound-interface eth0

            source {

                address 10.1.1.0/25

            }

            translation {

                address 50.103.55.99

            }

        }

    }

}

#配置静态路由

protocols {

    static {

        route 10.0.0.0/8 {

            next-hop 10.1.1.1 {

            }

            next-hop 10.1.1.126 {

            }

        }

    }

}

#配置DNS转发

service {

    dns {

        forwarding {

            cache-size 300

            listen-on eth1

            name-server 8.8.8.8    #8.8.8.8GOOGLE自己的DNS服务器

        }

    }

    telnet {

        port 23

    }

}

system {

    config-management {

        commit-revisions 20

    }

    console {

        device ttyS0 {

            speed 9600

        }

    }

    gateway-address 222.247.55.57

    host-name vyatta

    login {

        user vyatta {

            authentication {

                encrypted-password ****************

            }

            level admin

        }

    }

    ntp {

        server 0.vyatta.pool.ntp.org {

        }

        server 1.vyatta.pool.ntp.org {

        }

        server 2.vyatta.pool.ntp.org {

        }

    }

    package {

        auto-sync 1

        repository community {

            components main

            distribution stable

            password ****************

            url http://packages.vyatta.com/vyatta

            username ""

        }

    }

    syslog {

        global {

            facility all {

                level notice

            }

            facility protocols {

                level debug

            }

        }

    }

    time-zone GMT

}

#配置pptp  VPN拨号

vpn {

    pptp {

        remote-access {

            authentication {

                local-users {

                    username IBM{

                        password ****************

                    }

                }

                mode local

            }

   #VPN地址持

            client-ip-pool {

                start 10.1.1.70

                stop 10.1.1.74

            }

            outside-address 50.103.55.99

        }

    }

}

vyatta@vyatta:~$


0 0