大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 操作系统 -> Linux -> redhat linux9.0下nat代理的实现!

redhat linux9.0下nat代理的实现!

时间: 2021-07-31 作者:daque

在双网卡机子上,一张网卡(eth0)摆设61.185.11.101的ip另一张网卡(eth1)摆设摆设192.168.16.1这个ip.假造2张网卡(eth1:1和eth1:2)ip辨别是192.168.18.1和192.168.19.1(摆设文献在/etc/sysconfig/network-scripts/里。默许第一张网卡的摆设文献是ifcfg-eth0。第2张是ifcfg-eth1这2个文献都是有网卡就不妨机动天生的。最要害的是把假造网卡的摆设文献写出来。由于linux体例把一切摆设都是看成文献的。以是就在/etc/sysconfig/network-scripts/这个目次里用vi eth1:1,依照eth1的方法写一个eth1:1,不过ip不一律罢了。再写个eth1:2写完此后,都要重起一次网卡本领奏效。就用ifdown,和ifup吩咐。即使封闭网卡eth1就在吩咐行里输出ifdown eth1用route这个吩咐察看路由表。汇东配好了此后的是[root@router root]# routekernel ip routing tabledestination gateway genmask flags metric ref use iface219.221.176.0 * 255.255.255.0 u 0 0 0 eth0192.168.19.0 * 255.255.255.0 u 0 0 0 eth1192.168.18.0 * 255.255.255.0 u 0 0 0 eth1192.168.16.0 * 255.255.255.0 u 0 0 0 eth1169.254.0.0 * 255.255.0.0 u 0 0 0 eth1127.0.0.0 * 255.0.0.0 u 0 0 0 loydefault 219.221.176.1 0.0.0.0 ug 0 0 0 eth0[root@router root]#这个是精确的。这边最要害的是default 219.221.176.1 0.0.0.0 ug 0 0 0 eth0这条路由即使没有的话就本人树立.route add default gw 61.185.11.97(网关)这个格式还没有起用转发功效,路由也没有效,须要手动翻开。 在吩咐形式下输出echo 1 > /proc/sys/net/ipv4/ip_forward (为了不历次开机都要输出这个就写到启用剧本里。让它一开机机动启用。就把这条吩咐加到/etc/rc.d/rc.local这个文献里。好了。如许4个网段就连上清楚后即是摆设nat了。。nat即是作个ip假装。汇动的摆设是[root@router root]# cat /etc/rc.d/rc.locals#!/bin/sh## this script will be executed *after* all the other init scripts.# you can put your own initialization stuff in here if you don´t want to do the full sys v style init stuff.touch /var/lock/subsys/local#ifconfig eth1:1 192.168.18.1 up #开机机动假造eth1:1这个网卡ifconfig eth1:2 192.168.19.1 up #开机机动假造eth1:2这个网卡#!/bin/sh## this script will be executed *after* all the other init scripts.# you can put your own initialization stuff in here if you don´ t# want to do the full sys v style init stuff.touch /var/lock/subsys/localecho 1 > /proc/sys/net/ipv4/ip_forwardmodprobe ip_tablesmodprobe ip_nat_ftpmodprobe ip_nat_ircmodprobe ip_conntrackmodprobe ip_conntrack_ftpmodprobe ip_conntrack_irc/sbin/iptables -f/sbin/iptables -x/sbin/iptables -z/sbin/iptables -f -t nat/sbin/iptables -x -t nat/sbin/iptables -z -t nat/sbin/iptables -p input accept/sbin/iptables -p output accept/sbin/iptables -p forward accept/sbin/iptables -t nat -p prerouting accept/sbin/iptables -t nat -p postrouting accept/sbin/iptables -t nat -p output accept#jiazaimokuaimodprobe ip_tables 2> /dev/nullmodprobe ip_nat_ftp 2> /dev/nullmodprobe ip_nat_irc 2> /dev/nullmodprobe ip_conntrack 2> /dev/nullmodprobe ip_conntrack_ftp 2> /dev/nullmodprobe ip_conntrack_irc 2> /dev/null#ip weizhuang/sbin/iptables -t nat -a postrouting -o eth0 -s 192.168.0.0/24 -j masquerade

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.