[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經過通道送出去ide
ip ro re 203.117.0.0/16 via 1.54.16.2 dev bj06-us01 測試