linux下网络小常识!

简介:
1.检测服务器上ip地址是否生效/可用的方法
ping g.cn -I 服务器ip 表示使用本机的指定ip ping g.cn 如果可以ping通则表示正常
例如:美国刚买的ip  23.234.200.0/24
[root@PDS794 ~]# ping g.cn -I 23.234.200.251
PING g.cn (173.194.79.160) from 23.234.200.251 : 56(84) bytes of data.
64 bytes from pb-in-f160.1e100.net (173.194.79.160): icmp_seq=1 ttl=51 time=26.5 ms
64 bytes from pb-in-f160.1e100.net (173.194.79.160): icmp_seq=2 ttl=51 time=26.5 ms
64 bytes from pb-in-f160.1e100.net (173.194.79.160): icmp_seq=3 ttl=51 time=26.7 ms
2.通道的建立
例如: bj06-us01 1.54.16.1-2 210.51.3.31-198.148.124.34
cat >> /etc/rc.local <<\EOF
#bj06-us01
ip tunnel add bj06-us01 mode ipip remote 198.148.124.34 local 210.51.3.31
ip add add dev bj06-us01 1.54.16.1 peer 1.54.16.2
ifconfig bj06-us01 1.54.16.1/30
ip link set bj06-us01 up
route add -host 1.54.16.2 dev bj06-us01
EOF
#us01-bj06
ip tunnel add us01-bj06 mode ipip remote 210.51.3.31 local 198.148.124.34
ip add add dev us01-bj06 1.54.16.2 peer 1.54.16.1
ifconfig us01-bj06 1.54.16.2/30
ip link set us01-bj06 up
route add -host 1.54.16.1 dev us01-bj06
测试结果:
[root@bj06 ~]# alias ips
alias ips='ip route show'
[root@bj06 ~]# ips |grep us01
1.54.16.2 dev bj06-us01 scope link
1.54.16.0/30 dev bj06-us01 proto kernel scope link src 1.54.16.1
203.117.0.0/16 via 1.54.16.2 dev bj06-us01
[root@bj06 ~]# alias p
alias p='ping'
[root@bj06 ~]# p 1.54.16.2
PING 1.54.16.2 (1.54.16.2) 56(84) bytes of data.
64 bytes from 1.54.16.2: icmp_seq=1 ttl=64 time=223 ms
64 bytes from 1.54.16.2: icmp_seq=2 ttl=64 time=223 ms
64 bytes from 1.54.16.2: icmp_seq=3 ttl=64 time=224 ms
要改3个地方
1.私网ip  1.54.16.1-2
2.公网ip  210.51.3.31-198.148.124.34
3.接口名称  dev bj06-us01
为什么要建立通道
通过路由转发 如 ip route replace 这种方法比较灵活 比如说访问台服与国服使用不同的路由 如访问203.66.0.0/16(台服魔兽ip段)时走中台的路由 而访问国服魔兽(123.125.0.0/16)可以走到北京的路由
可以挡攻击 使用路由切换程序可以挡流量攻击
3. 163yum源
#换成163的yum源:
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.save
wget mirrors.163.com/.help/CentOS 5 -Base-163.repo
#wget mirrors.163.com/.help/CentOS 6 -Base-163.repo
sed -i 's/enabled=1/enabled=0/g' /etc/yum/pluginconf.d/fastestmirror.conf
cat /dev/null > /var/cache/yum/timedhosts.txt
yum clean all
yum makecache
[root@bj06 yum.repos.d]# ls /etc/yum.repos.d/
CentOS6-Base-163.repo CentOS-Debuginfo.repo CentOS-Vault.repo epel-testing.repo
CentOS-Base.repo CentOS-Media.repo epel.repo
除了它,其他的都可以备份下,暂时不用!

4.默认路由
查默认路由
[root@bj02 ~]# ip route show |grep def
default via 1.27.10.1 dev bj02-gz02c
查通道信息:
[root@bj02 ~]#  ifconfig |grep bj02-gz02c -A 6
bj02-gz02c Link encap:IPIP Tunnel HWaddr
inet addr:1.27.10.2 P-t-P:1.27.10.1 Mask:255.255.255.252
UP POINTOPOINT RUNNING NOARP MTU:1480 Metric:1
RX packets:1488769604 errors:0 dropped:0 overruns:0 frame:0
TX packets:1702443750 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2923348000 (2.7 GiB) TX bytes:99236479 (94.6 MiB)
[root@bj02 ~]#  cat /etc/rc.local |grep bj02- gz02c 可查出对端的ip
#bj02-gz02c
ip tunnel add bj02-gz02c mode ipip remote  116.213.249.196 local 202.108.54.10
ip add add dev bj02-gz02c 1.27.10.2 peer 1.27.10.1
ifconfig bj02-gz02c 1.27.10.2/30
ip link set bj02-gz02c up
route add -host 1.27.10.1 dev bj02-gz02c
ip route replace default via 1.27.10.1 dev bj02-gz02c
拥有国际出口的默认路由:
[root@gz02 ~]# ifconfig |grep 116.213.249.196
inet addr:116.213.249.196 Bcast:116.213.249.223 Mask:255.255.255.224
[root@gz02 ~]# ip route show |grep default
default via 203.78.190.14 dev em2  直接从接口出去
You have new mail in /var/spool/mail/roo
如何修改默认路由:
[root@bj02 ~]# ip ro re 0.0.0.0/0 via 1.54.10.1 dev bj02-bj06
[root@bj02 ~]# ips |grep def

default via 1.54.10.1 dev bj02-bj06

调整路由的方法和修改默认路由的方法类似,如把 台服lol的认证ip 203.117网段通过bj06通过通道送出去

ip ro re 203.117.0.0/16 via 1.54.16.2 dev bj06-us01



本文转自 gjp0731 51CTO博客,原文链接:http://blog.51cto.com/guojiping/1319596


相关文章
|
9月前
|
安全 Linux 网络安全
Nipper 3.9.0 for Windows & Linux - 网络设备漏洞评估
Nipper 3.9.0 for Windows & Linux - 网络设备漏洞评估
252 0
Nipper 3.9.0 for Windows & Linux - 网络设备漏洞评估
|
10月前
|
运维 Linux 开发者
Linux系统中使用Python的ping3库进行网络连通性测试
以上步骤展示了如何利用 Python 的 `ping3` 库来检测网络连通性,并且提供了基本错误处理方法以确保程序能够优雅地处理各种意外情形。通过简洁明快、易读易懂、实操性强等特点使得该方法非常适合开发者或系统管理员快速集成至自动化工具链之内进行日常运维任务之需求满足。
673 18
|
10月前
|
网络协议 关系型数据库 Linux
【App Service Linux】在Linux App Service中安装 tcpdump 并抓取网络包
在App Service for Linux环境中,无法像Windows一样直接使用网络排查工具抓包。本文介绍了如何通过TCPDUMP在Linux环境下抓取网络包,包括SSH进入容器、安装tcpdump、执行抓包命令及下载分析文件的完整操作步骤。
494 5
|
11月前
|
Web App开发 网络协议 Linux
【Linux】网络基础
TCP/IP五层模型是网络通信的基础框架,将复杂的数据传输过程分为物理层、数据链路层、网络层、传输层和应用层,每层各司其职,协同完成远程通信。该模型确保了不同设备和网络之间的互联互通,是现代互联网运行的核心机制。
1283 5
|
安全 网络协议 Linux
Linux网络应用层协议展示:HTTP与HTTPS
此外,必须注意,从HTTP迁移到HTTPS是一项重要且必要的任务,因为这不仅关乎用户信息的安全,也有利于你的网站评级和粉丝的信心。在网络世界中,信息的安全就是一切,选择HTTPS,让您的网站更加安全,使您的用户满意,也使您感到满意。
398 19
|
11月前
|
网络协议 Linux 开发者
深入Linux中UDP网络通信机制编程探索
以上步骤概述了Linux中UDP网络通信的编程机制。在实现时,因关注细节和上下文环境可能有所调整,但大致流程是一致的。这些知识片段旨在帮助开发者快速上手Linux下的UDP编程,并提供可靠的信息作为编程的基础。在编程实践中,应结合实际业务需求,设计合适的数据传输协议,确保数据的正确性和实时性。
246 0
|
Linux 数据安全/隐私保护
使用Linux命令行接入无线网络Wi-Fi的示例。
现在,你已经使用命令行成功地连接到 Wi-Fi 网络了。这两个示例涵盖了用 `nmcli` 和 `wpa_supplicant` 连接无线网络的常见场景,让你能够不依赖图形化界面来完成这个任务。在日常使用中熟练掌握这些基本操作能增强你对 Linux 系统的理解,帮助你更有效地处理各种问题。
1081 12
|
安全 Ubuntu Linux
Nipper 3.8.0 for Windows & Linux - 网络设备漏洞评估
Nipper 3.8.0 for Windows & Linux - 网络设备漏洞评估
582 0
Nipper 3.8.0 for Windows & Linux - 网络设备漏洞评估
|
Ubuntu Linux
Linux系统管理:服务器时间与网络时间同步技巧。
以上就是在Linux服务器上设置时间同步的方式。然而,要正确运用这些知识,需要理解其背后的工作原理:服务器根据网络中的其他机器的时间进行校对,逐步地精确自己的系统时间,就像一只犹豫不决的啮齿动物,通过观察其他啮齿动物的行为,逐渐确定自己的行为逻辑,既简单,又有趣。最后希望这个过程既能给你带来乐趣,也能提高你作为系统管理员的专业素养。
2354 20
|
JSON 运维 Ubuntu
Linux下如何使用Curl进行网络请求
希望这篇文章能帮助您在Linux下更好地使用Curl进行网络请求。如有疑问,请随时提问!
839 10