国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

Linux|Centos|Ubuntu|系統進程|Fedora|注冊表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服務器之家 - 服務器系統 - Centos - CentOS7下如何配置ip forward(虛擬路由器)

CentOS7下如何配置ip forward(虛擬路由器)

2022-02-17 20:24Leshami Centos

本篇文章主要介紹了CentOS7下如何配置ip forward(虛擬路由器),非常具有實用價值,需要的朋友可以參考下

linux 中ip forward功能是一個比較方便實用的功能,只需要簡單配置,添加幾條路由,即可實現ip轉發。本文基于centos 7下采取一臺機器充當虛擬路由,來實現windows環境與linux環境中相互通信。具體見下文,供大家參考。

一、環境及需求說明

CentOS7下如何配置ip forward(虛擬路由器)

本地測試環境,由于win7+vmware這臺機器網卡太新,無法被vmware exsi識別,無奈之下就直接裝了個win7,然后再上面基于vmware workstation 12開啟了一些臨時測試的虛擬機。其次本地直連網段192.168.1.0 ip有限,而又希望直接從本機(如圖win10) ssh連接到這些虛擬機,因此考慮使用linux的ip轉發功能來實現。

上述圖片中已經列出了各個節點的ip信息,紅色的虛擬機充當軟路由,配置好之后,實現win10 直接ssh到虛擬機。

二、虛擬路由服務器配置

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
###查看網卡信息
[root@centos7-router ~]# ip addr
1: lo: <loopback,up,lower_up> mtu 65536 qdisc noqueue state unknown
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
  inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
2: eno16777728: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state up qlen 1000
  link/ether 00:0c:29:9c:eb:2d brd ff:ff:ff:ff:ff:ff
  inet 172.24.8.254/24 brd 172.24.8.255 scope global eno16777728
   valid_lft forever preferred_lft forever
  inet6 fe80::20c:29ff:fe9c:eb2d/64 scope link
   valid_lft forever preferred_lft forever
3: eno33554960: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state up qlen 1000
  link/ether 00:0c:29:9c:eb:37 brd ff:ff:ff:ff:ff:ff
  inet 192.168.1.175/24 brd 192.168.1.255 scope global dynamic eno33554960
   valid_lft 82384sec preferred_lft 82384sec
  inet6 fe80::20c:29ff:fe9c:eb37/64 scope link
   valid_lft forever preferred_lft forever
 
###查看路由表
[root@centos7-router ~]# route -n
kernel ip routing table ###缺省情況下,每塊網卡都有一個基于本網段的路由記錄
destination  gateway    genmask    flags metric ref  use iface
0.0.0.0    192.168.1.1  0.0.0.0    ug  100  0    0 eno33554960
172.24.8.0   0.0.0.0    255.255.255.0 u  100  0    0 eno16777728
192.168.1.0  0.0.0.0    255.255.255.0 u  100  0    0 eno33554960
 
###使用ip命令方式查看路由
[root@centos7-router ~]# ip route list
default via 192.168.1.1 dev eno33554960 proto static metric 100
172.24.8.0/24 dev eno16777728 proto kernel scope link src 172.24.8.254 metric 100
192.168.1.0/24 dev eno33554960 proto kernel scope link src 192.168.1.175 metric 100
 
###開啟ip forward
[root@centos7-router ~]# cp /usr/lib/sysctl.d/50-default.conf /usr/lib/sysctl.d/50-default.conf.bk
[root@centos7-router ~]# echo "net.ipv4.ip_forward = 1" >>/usr/lib/sysctl.d/50-default.conf
[root@centos7-router ~]# grep ip_forward /usr/lib/sysctl.d/50-default.conf
net.ipv4.ip_forward = 1
[root@centos7-router ~]# sysctl -p ###如不生效重啟一下os

三、centos7-a主機下添加路由

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
###查看當前主機ip 信息
[root@centos7-a ~]# ip addr list
1: lo: <loopback,up,lower_up> mtu 65536 qdisc noqueue state unknown
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
  inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
2: eno16777728: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state up qlen 1000
  link/ether 00:0c:29:57:26:9d brd ff:ff:ff:ff:ff:ff
  inet 172.24.8.131/24 brd 172.24.8.255 scope global dynamic eno16777728
   valid_lft 1088sec preferred_lft 1088sec
  inet6 fe80::20c:29ff:fe57:269d/64 scope link
   valid_lft forever preferred_lft forever
 
###查看當前主機路由信息  
[root@centos7-a ~]# ip route list
172.24.8.0/24 dev eno16777728 proto kernel scope link src 172.24.8.131 metric 100
 
[root@centos7-a ~]# # author : leshami
[root@centos7-a ~]# # blog : http://blog.csdn.net/leshami
[root@centos7-a ~]# ip route add default via 172.24.8.254
[root@centos7-a ~]# ip route list
default via 172.24.8.254 dev eno16777728
172.24.8.0/24 dev eno16777728 proto kernel scope link src 172.24.8.131 metric 100
 
###測試到虛擬路由器網關ip連通性
[root@centos7-a ~]# ping 172.24.8.254 -c 2      
ping 172.24.8.254 (172.24.8.254) 56(84) bytes of data.
64 bytes from 172.24.8.254: icmp_seq=1 ttl=64 time=0.268 ms
64 bytes from 172.24.8.254: icmp_seq=2 ttl=64 time=0.302 ms
 
--- 172.24.8.254 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.268/0.285/0.302/0.017 ms
 
###測試到虛擬路由器ip連通性
[root@centos7-a ~]# ping 192.168.1.175 -c 2
ping 192.168.1.175 (192.168.1.175) 56(84) bytes of data.
64 bytes from 192.168.1.175: icmp_seq=1 ttl=64 time=0.475 ms
64 bytes from 192.168.1.175: icmp_seq=2 ttl=64 time=0.443 ms
 
--- 192.168.1.175 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.443/0.459/0.475/0.016 ms

四、windows 10下配置路由

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
###當前環境
c:\>systeminfo | findstr build
os version:        10.0.14393 n/a build 14393
os build type:      multiprocessor free
 
###查看當前的路由信息
c:\>route print -4
===========================================================================
interface list
 7...54 ab 3a xx b8 ea ......intel(r) ethernet connection i219-v
21...ac 2b 6e 5f 3b 57 ......microsoft wi-fi direct virtual adapter
            ......
===========================================================================
ipv4 route table
===========================================================================
active routes:
network destination    netmask     gateway   interface metric
     0.0.0.0     0.0.0.0   192.168.1.1  192.168.1.242  35
    127.0.0.0    255.0.0.0    on-link    127.0.0.1  331
    127.0.0.1 255.255.255.255    on-link    127.0.0.1  331
 127.255.255.255 255.255.255.255    on-link    127.0.0.1  331
   172.24.10.0  255.255.255.0    on-link   172.24.10.1  291
   172.24.10.1 255.255.255.255    on-link   172.24.10.1  291
  172.24.10.255 255.255.255.255    on-link   172.24.10.1  291
   192.168.1.0  255.255.255.0    on-link  192.168.1.242  291
  192.168.1.242 255.255.255.255    on-link  192.168.1.242  291
  192.168.1.255 255.255.255.255    on-link  192.168.1.242  291
  192.168.16.0  255.255.255.0    on-link   192.168.16.1  291
  192.168.16.1 255.255.255.255    on-link   192.168.16.1  291
 192.168.16.255 255.255.255.255    on-link   192.168.16.1  291
    224.0.0.0    240.0.0.0    on-link    127.0.0.1  331
    224.0.0.0    240.0.0.0    on-link  192.168.1.242  291
    224.0.0.0    240.0.0.0    on-link   192.168.16.1  291
    224.0.0.0    240.0.0.0    on-link   172.24.10.1  291
 255.255.255.255 255.255.255.255    on-link    127.0.0.1  331
 255.255.255.255 255.255.255.255    on-link  192.168.1.242  291
 255.255.255.255 255.255.255.255    on-link   192.168.16.1  291
 255.255.255.255 255.255.255.255    on-link   172.24.10.1  291
===========================================================================
persistent routes:
 none
 
###添加持久化路由
c:\>route add 172.24.8.0 mask 255.255.255.0 192.168.1.175 -p
ok!
 
c:\>route print -4
 
ipv4 route table
===========================================================================
active routes:
network destination    netmask     gateway   interface metric
     0.0.0.0     0.0.0.0   192.168.1.1  192.168.1.242  35
    127.0.0.0    255.0.0.0    on-link    127.0.0.1  331
    127.0.0.1 255.255.255.255    on-link    127.0.0.1  331
 127.255.255.255 255.255.255.255    on-link    127.0.0.1  331
   172.24.8.0  255.255.255.0  192.168.1.175  192.168.1.242  36
   172.24.10.0  255.255.255.0    on-link   172.24.10.1  291
   172.24.10.1 255.255.255.255    on-link   172.24.10.1  291
  172.24.10.255 255.255.255.255    on-link   172.24.10.1  291
   192.168.1.0  255.255.255.0    on-link  192.168.1.242  291
  192.168.1.242 255.255.255.255    on-link  192.168.1.242  291
  192.168.1.255 255.255.255.255    on-link  192.168.1.242  291
  192.168.16.0  255.255.255.0    on-link   192.168.16.1  291
  192.168.16.1 255.255.255.255    on-link   192.168.16.1  291
 192.168.16.255 255.255.255.255    on-link   192.168.16.1  291
    224.0.0.0    240.0.0.0    on-link    127.0.0.1  331
    224.0.0.0    240.0.0.0    on-link  192.168.1.242  291
    224.0.0.0    240.0.0.0    on-link   192.168.16.1  291
    224.0.0.0    240.0.0.0    on-link   172.24.10.1  291
 255.255.255.255 255.255.255.255    on-link    127.0.0.1  331
 255.255.255.255 255.255.255.255    on-link  192.168.1.242  291
 255.255.255.255 255.255.255.255    on-link   192.168.16.1  291
 255.255.255.255 255.255.255.255    on-link   172.24.10.1  291
===========================================================================
persistent routes: ###以下為添加的持久化路由記錄
 network address     netmask gateway address metric
   172.24.8.0  255.255.255.0  192.168.1.175   1
===========================================================================

五、驗證兩邊連通性

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
###從linux端ping windows 10
[root@centos7-a ~]# ping 192.168.1.242 -c 2  
ping 192.168.1.242 (192.168.1.242) 56(84) bytes of data.
64 bytes from 192.168.1.242: icmp_seq=1 ttl=63 time=1.70 ms
64 bytes from 192.168.1.242: icmp_seq=2 ttl=63 time=1.10 ms
 
--- 192.168.1.242 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 1.101/1.404/1.707/0.303 ms
 
###從windows 10端ping linux
c:\>ping 172.24.8.131 -t
 
pinging 172.24.8.131 with 32 bytes of data:
reply from 172.24.8.131: bytes=32 time=1ms ttl=63
reply from 172.24.8.131: bytes=32 time=1ms ttl=63

注,如果測試有問題,請考慮是否被防火墻攔住。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。

原文鏈接:http://blog.csdn.net/leshami/article/details/78123995?utm_source=tuicool&utm_medium=referral

延伸 · 閱讀

精彩推薦
  • CentosCentOS 6.6實現永久修改DNS地址的方法

    CentOS 6.6實現永久修改DNS地址的方法

    這篇文章主要介紹了CentOS 6.6實現永久修改DNS地址的方法,涉及針對CentOS配置文件的相關設置技巧,具有一定參考借鑒價值,需要的朋友可以參考下 ...

    Linux社區4472020-08-21
  • CentosCentOS6.5下Redis安裝與配置詳細步驟

    CentOS6.5下Redis安裝與配置詳細步驟

    本篇文章主要介紹了CentOS6.5下Redis安裝與配置詳細步驟,詳細介紹redis單機單實例安裝與配置,服務及開機自啟動。有興趣的可以了解一下。...

    飛流11452021-12-24
  • Centoscentos 安裝與操作方法

    centos 安裝與操作方法

    這篇文章主要介紹了centos 安裝與操作方法,需要的朋友可以參考下...

    centos之家5272019-07-11
  • CentosCentOS下Uptime命令詳解

    CentOS下Uptime命令詳解

    在Linux下,我們可以使用uptime命令,而且此命令不必使用root權限。uptime命令在系統中已經默認安裝了。今天小編為大家帶來的是CentOS下Uptime命令詳解;希望...

    CentOS之家11482019-06-19
  • CentosCentOS7設置日期和時間方法以及基本概念介紹

    CentOS7設置日期和時間方法以及基本概念介紹

    這篇文章主要介紹了CentOS7設置日期和時間方法以及基本概念介紹,本文講解使用CentOS7中的新命令timedatectl設置日期時間方法,需要的朋友可以參考下 ...

    CentOS之家6522019-09-19
  • CentosCentos7運用/dev/shm進行網站優化

    Centos7運用/dev/shm進行網站優化

    這篇文章主要介紹了LINUX中Centos7運用/dev/shm進行網站優化相關知識點,對此有興趣的朋友參考學習下。...

    彬菌9912022-03-02
  • CentosCentos 7開啟網卡自動獲取IP的詳細方法

    Centos 7開啟網卡自動獲取IP的詳細方法

    本篇文章主要介紹了Centos 7開啟網卡自動獲取IP的詳細方法,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧...

    凌鋒8972021-12-29
  • Centoscentos不小心刪除/root目錄該如何解決?

    centos不小心刪除/root目錄該如何解決?

    一些朋友最近在問小編centos不小心刪除/root目錄該如何解決?今天小編就為大家分享centos不小心刪除/root目錄解決辦法;希望對大家會有幫助,有需要的朋友...

    腳本之家8022019-05-29
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 久久精品亚洲一区二区 | www国产在线观看 | 蜜桃成人在线视频 | 永久黄网站色视频免费观看w | 激情久久av一区av二区av三区 | 欧美高清在线 | 亚洲国产精品久久久久 | 亚洲精品乱码久久久久久蜜桃不爽 | 韩日av在线免费观看 | 中文字幕av一区二区 | 国产91久久久久蜜臀青青天草二 | 一级毛片免费高清 | 国产h片在线观看 | 国产一区二区三区高清 | 国产精品日韩在线观看 | 一级爱 | 欧美黄色一区 | 亚洲一区二区中文 | 欧美精品日韩 | 久久久亚洲国产天美传媒修理工 | 999久久久国产999久久久 | 免费一区二区三区四区 | 久久精品亚洲成在人线av网址 | 黄色国产 | 草久久| 国产精品高清在线 | 黄色动漫在线观看 | 欧美性一区 | 欧美日韩亚洲综合 | 久久久久久综合 | 久久亚洲一区二区三区四区 | 亚洲精品在线播放视频 | 天天夜夜操 | 久久亚洲欧美日韩精品专区 | 国产成人欧美一区二区三区的 | 国产黄色免费网站 | 欧美第一网站 | 精品久久久久久久久久久久久久 | 国产精品一区二区久久 | 久久99久久久久久 | 一区免费视频 |