linux查看nat表(路由器查看nat表)

      最后更新:2024-03-28 16:11:28 手机定位技术交流文章

      linux下怎么抓nat的数据包

      1. 配置IP地址 1.1 正确配置学校分配的IP使能正常上网1) 按学校分配的IP地址配置好Linux主机[~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0| DEVICE=eth0 || BOOTPROTO=none || HWADDR=00:1E:90:13:E0:25 || IPADDR=10.3.10.19 || NETMASK=255.255.255.0 || GATEWAY=10.3.10.254 || ONBOOT=yes || TYPE=Ethernet || DNS1=211.64.120.2 || DEFROUTE=yes || DOMAIN=168.96.1.1 |2) 重起网卡[~]# servie network restartnote: 经过以上的配置, Linux主机应该能够正常上网了!1.2 新增eth0别名设备eth0:0[~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0:0| # eth0:0 必须要用''括起来: 'eth0:0' || DEVICE='eth0:0' || ONBOOT=yes || BOOTPROTO=static || IPADDR=192.168.50.1 || NETMASK=255.255.255.0 || USERCTL=no |1.3 配置后 查看一下是否配置成功:[~]# ifconfig| eth0 Link encap:Ethernet HWaddr 00:1E:90:13:E0:25 || inet addr:10.3.10.19 Bcast:10.3.10.255 Mask:255.255.255.0 || inet6 addr: fe80::21e:90ff:fe13:e025/64 Scope:Link || UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1 || RX packets:187685 errors:0 dropped:0 overruns:0 frame:0 || TX packets:137327 errors:0 dropped:0 overruns:0 carrier:0 || collisions:0 txqueuelen:1000 || RX bytes:134816893 (128.5 MiB) TX bytes:56066393 (53.4 MiB) || Interrupt:27 Base address:0xa000 || eth0:0 Link encap:Ethernet HWaddr 00:1E:90:13:E0:25 || inet addr:192.168.50.1 Bcast:192.168.50.255 Mask:255.255.255.0 || UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1 || Interrupt:27 Base address:0xa000 |2. 配置路由由于在配置网卡接口时, 已自动配置一定的路由, 所以我们只需查看一下其信息, 验证其是否已经被正确配置:[root ~]$ routeKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface192.168.50.0 * 255.255.255.0 U 0 0 0 eth010.3.10.0 * 255.255.255.0 U 1 0 0 eth0link-local * 255.255.0.0 U 1002 0 0 eth0default 10.3.10.254 0.0.0.0 UG 0 0 0 eth03. 配置NAT1) 新建nat.sh脚本文件并保存在 /usr/local/nat/ 目录下:[~]# cat /usr/local/nat/nat.sh| #!/bin/bash || # 0. 设定你的参数值 || EXIF='eth0' # 这个是对外的网卡接口, 可能是'ppp0'等 || EXNET='192.168.50.0/24' # 这个是对内的网段 || # 底下如无需要, 请不要改动了! || # 1. 启动routing等 || echo 1 > /proc/sys/net/ipv4/ip_forward || /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 || # 2. 载入模组 || /sbin/modprobe ip_tables 2> /dev/null || /sbin/modprobe ip_nat_ftp 2> /dev/null || /sbin/modprobe ip_nat_irc 2> /dev/null || /sbin/modprobe ip_conntrack 2> /dev/null || /sbin/modprobe ip_conntrack_ftp 2> /dev/null || /sbin/modprobe ip_conntrack_irc 2> /dev/null || # 3. 启动ip伪装 || /sbin/iptables -t nat -A POSTROUTING -o $EXIF -s $EXNET -j MASQUERADE |2) 增加可执行权限[~]# chmod +x /usr/local/nat/nat.sh4. 大功告成1) Linux主机配置完成, 现在只需重新启动一下刚才的配置:[~]# servie network restart[~]# /usr/local/nat/nat.sh2) 为了使得开机即可运行, 可在 /etc/rc.d/rc.local 文件加入相应的命令:[~]# echo "/usr/local/nat/nat.sh" >> /etc/rc.d/rc.local5. 配置客户机(可以是windows或linux等其它系统)1. network 设定需要为: 192.168.50.02. broadcast 设定需要为: 192.168.50.2553. netmask 设定需要为 255.255.255.04. IP 设定需要为 192.168.50.1 ~ 192.168.50.254 之一, 且『不能重复』5. Gateway 或者要设定为你的 Linux 的对内 IP , 以我的例子来说, 就是192.168.50.16. DNS 的设定: 这个最容易出错了, DNS 设定需要是 ISP 给你的 DNSIP, 如果不知道的话, 可以填入 168.95.1.1 或者是 139.175.10.20 这一个 SeedNet 的 DNS 即可!千万不要设定为 192.168.1.2
      tcpdump -s0 -nn -A |grep -10 xxx 这个可以吗?
      linux下怎么抓nat的数据包

      linux下怎么查看网卡是桥接还是nat

      桥接还是nat是指虚拟机,如果你不是在虚拟机下跑的可以不去考虑了,如果是那么在虚拟机的配置文件里面可以看的到的,不会追问
      肯定是在虚拟机下吧 你把虚拟机缩小化后点击编辑里面的倒数第二项就显示出来了 当前显示的就是
      上配置文件
      linux下怎么查看网卡是桥接还是nat

      是否有办法看到实时的linux中nat 映射表

      POSTROUTING时,-o从理论上说,是有必要保留的,否则会有一些你不希望NAT但实际却被NAT的数据包在网间传递。比如NAT主机有重定向路由,或者NAT主机多出口的时候。 不通应该是你拨号后,ppp端口不是ppp0而是ppp1、ppp2……依次往下排了,ppp0已经成...
      是否有办法看到实时的linux中nat 映射表

      如何查看linux的iptables配置

      1、用iptables命令直接查看[root@test ~]# iptables -nv -L#-L是--list的简写,作用是列出规则2、直接查看iptables的配置文档[root@test ~]# more /etc/sysconfig/iptables
      iptables -nL 如果想查看其它表的话就需要指定表明,如NAT等。
      命令行 iptables -l
      1、iptables -nvL 2、more /etc/sysconfig/iptables
      如何查看linux的iptables配置

      Linux中iptalbes -t nat -nvL是什么意思

      iptables是Linux中的一个防火墙,它常用的有三个表(filter,nat,mangle),每个表有三个链(input,forward,output) iptables -t 表名是指定nat表-nvL 这其实是三个参数,等效于 -n -v -L-n 不解析主机名和端口名,也就是全部主机和端口都用数字表示-v 详细信息列表-L 列表具体参考 iptables -h[root@localhost ~]# iptables -hiptables v1.3.5Usage: iptables -[AD] chain rule-specification [options]iptables -[RI] chain rulenum rule-specification [options]iptables -D chain rulenum [options]iptables -[LFZ] [chain] [options]iptables -[NX] chainiptables -E old-chain-name new-chain-nameiptables -P chain target [options]iptables -h (print this help information)Commands:Either long or short options are allowed.--append-A chainAppend to chain--delete-D chainDelete matching rule from chain--delete-D chain rulenumDelete rule rulenum (1 = first) from chain--insert-I chain [rulenum]Insert in chain as rulenum (default 1=first)--replace -R chain rulenumReplace rule rulenum (1 = first) in chain--list-L [chain]List the rules in a chain or all chains--flush -F [chain]Delete all rules inchain or all chains--zero-Z [chain]Zero counters in chain or all chains--new -N chainCreate a new user-defined chain--delete-chain-X [chain]Delete a user-defined chain--policy-P chain targetChange policy on chain to target--rename-chain-E old-chain new-chainChange chain name, (moving any references)Options:--proto -p [!] protoprotocol: by number or name, eg. `tcp'--source-s [!] address[/mask]source specification--destination -d [!] address[/mask]destination specification--in-interface -i [!] input name[+]network interface name ([+] for wildcard)--jump-j targettarget for rule (may load target extension)--goto-g chainjump to chain with no return--match -m matchextended match (may load extension)--numeric -nnumeric output of addresses and ports--out-interface -o [!] output name[+]network interface name ([+] for wildcard)--table -t tabletable to manipulate (default: `filter')--verbose -vverbose mode--line-numbersprint line numbers when listing--exact -xexpand numbers (display exact values)[!] --fragment-fmatch second or further fragments only--modprobe=try to insert modules using this command--set-counters PKTS BYTES set the counter during insert/append[!] --version -Vprint package version. [root@localhost ~]#
      查询nat表的详细信息 -n 不解析主机名和端口名,-v 详细信息,-L 列表形式显示
      Linux中iptalbes -t nat -nvL是什么意思

      本文由 在线网速测试 整理编辑,转载请注明出处,原文链接:https://www.wangsu123.cn/news/312412.html

          热门文章

          文章分类