iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 15
1
自我挑戰組

Linux學習系列 第 15

Ubuntu /etc/network/interfaces和了解四種backbones裝置、靜態與動態ip、VPN

  • 分享至 

  • twitterImage
  •  

前篇的Apache2已經可以顯示在自己的主機了,接下來就是要顯示到所有裝置

網址:
How can I access Apache (on VirtualBox guest) from host?
Ubuntu 18.04: switch back to /etc/network/interfaces

1 Settings > Network > Adapter 1 (Enable Network Adapter) > Attached to: (Bridge Adapter) > OK
https://ithelp.ithome.com.tw/upload/images/20181028/20111994hN61KJn4ni.png
2 開機並輸入以下指令(換成root使用者):
#apt-get update
#apt-get install ifupdown
3 編輯這個檔案
nano /etc/network/interfaces
https://ithelp.ithome.com.tw/upload/images/20181028/20111994Tb3rMxh7TA.png
4 #ifdown --force enp0s3 lo && ifup -a
5 接著只要在同個網路(同個公有ip)任一裝置輸入192.168.0.107都可以看到Apache2 Ubuntu

完成之後,來了解一些名詞(以下截圖來自影片):
The Difference Between Hubs, Bridges, Switches and Gateways (Backbones)

影片中介紹了四種backbones裝置:
hub,bridge,switch,gateway:
https://ithelp.ithome.com.tw/upload/images/20200813/20111994W9O6QO1wyp.png

集線器(Ethernet hub)

1 將多條乙太網路雙絞線或光纖集合連接在同一段物理媒介下的裝置。
2 集線器是在OSI模型中的實體層,
3 集線器上有多個I/O埠,訊號從任意一個埠進入後,會從其他所有埠出現。
4 於集線器會把收到的任何數位訊號,經過再生或放大,再從集線器的所有埠送出,這會造成訊號之間碰撞的機會很大,而且訊號也可能被竊聽,並且這代表所有連到集線器的裝置,都是屬於同一個碰撞網域以及廣播網域,因此大部份集線器已被交換機(英語:Network switch)取代。
來源:集線器

如圖,如果有一個資料要從server1送出,經過hub後,不能指定送到哪個PC
而是要送到所有的PC
https://ithelp.ithome.com.tw/upload/images/20181028/2011199475n2bRlZKH.png
https://ithelp.ithome.com.tw/upload/images/20181028/20111994KMn8Cyv0AU.png

如果有兩個電腦同時送出資料,資料會碰撞。因為PC2和PC3都會送資料到PC4,這樣到PC4的資料就會碰撞
https://ithelp.ithome.com.tw/upload/images/20181028/20111994QRG62EDeas.png

橋接器(英語:network bridge)

1 又稱網橋,一種網路裝置,負責網路橋接(network bridging)之用。
2 橋接器是在資料鏈路層(OSI模型第2層)。
3 橋接器可以讓PC3選擇送資料到哪個PC,這邊就送到Server1和PC4
https://zh.wikipedia.org/wiki/%E6%A9%8B%E6%8E%A5%E5%99%A8
https://ithelp.ithome.com.tw/upload/images/20181028/20111994wNfbnAq3Zm.png
https://ithelp.ithome.com.tw/upload/images/20181028/20111994FVwmQhOTLv.png

網路交換器(英語:Network switch)是一種網路資料轉發裝置,能夠對封包進行高速地「交換」。

為什麼是高速地「交換」?
因為如圖,每個裝置都有兩條路線,所以可以同時傳送和接收,而且可以
同時送資料給switch,不會像hub會資料碰撞
https://ithelp.ithome.com.tw/upload/images/20181028/20111994Z8dzZDfbZ0.png

Gateway:

指把一種協定轉成另一種協定的裝置。如圖PC使用乙太網路(英語:Ethernet)和TCP/IP協定,PLC使用Sub Net(子網路)和Controlled Net Protocol(網絡控制協議)網路和協定都不同,但是有Gateway的話,還是可以傳資料,TCP/IP經過Gateway後就會變成Controlled Net Protocol
https://ithelp.ithome.com.tw/upload/images/20181028/20111994MTxh3WSfc4.png
https://ithelp.ithome.com.tw/upload/images/20181028/20111994AekKA4k604.png

接著來了解什麼是static ip

10 Difference Between Static And Dynamic Ip Address

1 When a device is assigned a static IP address, the address does not change.

靜態ip是不會變的ip,重開機還是一樣的ip

2 A dynamic IP address is an IP address dynamically assigned to your computer by your ISP. Each time your computer (or router) is rebooted, your ISP dynamically assigns an IP address to your networking device using DHCP protocol.

動態ip是ISP透過DHCP protocol分配的地址。重開機就會換

關於ISP是什麼:
什麼是ISP網際網路連線服務公司(Internet Service Provider)?

查詢dynamic IP

動態主機設定協定(英語:Dynamic Host Configuration Protocol,DHCP)
動態主機設定協定
一 使用UDP協定
二 用於內部網路或網路服務供應商自動分配IP位址給用戶
三 用於內部網路管理員作為對所有電腦作中央管理的手段

3 Static Ip address is better for dedicated services such as mail, FTP and VPN servers.

靜態ip適合用在mail,FTP and VPN這些功能的伺服器

4 A dynamic IP address is suitable if you have:
several computers on an internal network with internet access on all of them.

動態ip適合用在私有網路的每台電腦都需要連到internet

5 A static IP address is suitable if you:
run your own website.
run your own email server.

靜態ip適合網頁或郵件的伺服器

6 Dynamic IP address Advantages:
Cheaper than static IP address.
Changing IP address gives more privacy.

Dynamic IP address比static IP address便宜,然後比較隱蔽,因為會更改

7 if you have a dynamic IP address, Geolocation might be less accurate, if that matters to you.

如果是動態ip,當要透過ip查地理位置可能比較不準確

8 Static IP addresses have a number of advantages. They can give you:
less downtime - there is a risk of downtime when new dynamic IP addresses are allocated
remote access - you can access your own PC from anywhere in the world with static IP

靜態ip可以讓電腦比較不容易壞掉,因為不像動態ip會更換
遠端連線,不論在哪個地方都可以連到使用靜態ip的電腦

9 Dynamic IP address Disadvantages:
一 Requires DHCP server to obtain an IP address.
二 Non-static. Each time IP address changes, you may have to find you IP address again.

動態IP缺點:需要DHCP server來創IP、當IP address 改變時,就要再確認IP到底是多少

10 A dynamic IP address is suitable if you have:
a single computer that connects to your head office on a one-way Virtual Private Network

動態ip適合一台遠端到總公司的電腦,透過vpn

VPN

這篇文章寫得很清楚:
So what is a VPN, and why should you care?

VPN是加密的。原本自己的公有ip會換成VPN SERVER的公有ip,所以自己的ip是不會到網路的,也就是說網頁伺服器會不知道自己使用的電信商,也就不會知道自己的地理位置
https://cdn57.androidauthority.net/wp-content/uploads/2016/06/vpn-the-internet-with-vpn-1200x675.jpg

VPN的用途

A example might be if I am traveling on a business trip outside of my normal country of residence and I want to watch TV from my home country. Most of the time this won’t be possible as the catch-up service (like the BBC iPlayer) will tell me that the content isn’t available outside of the UK. This is also true of services like Hulu, Netflix, and Amazon Video.

VPN的用途像是:今天去別的國家,但是我要看我的國家的電視,通常都是不能看的。例如: BBC iPlayer會說:這只能在英國看,其他的還有Hulu, Netflix, and Amazon Video。

The upshot of this encrypted connection is that your data has the IP address that is assigned to the other end of the tunnel, not your home. That means that when you connect to a web server the IP address seen by the server is that of the VPN endpoint, not your home IP address. So now if you access a sensitive site then your IP address and location are not exposed. Also if you are travelling you can connect to a VPN endpoint in your home country and access content as if you were at home.

VPN就是原本自己的ip換成VPN的ip。所以原本自己國家不能看的內容,換成VPN就可以。

There is also another surprising benefit. Some online services charge different amounts depending on your location. Personally I have bought stuff cheaper by connecting via a VPN to convince the online service than I am in the USA and not in Europe. This also applies to airfares. Express VPN did a study which shows that there are big pricing differences when buying tickets online depending on your location.

VPN的功能還有:各個國家的商品價錢不同,有的便宜,有的貴,VPN可以選擇要在哪個國家,這樣就可以省錢。

VPN的缺點

VPNs are a great solution to the privacy issues I have outlined, however VPNs aren’t a perfect solution, there are a few negative aspects. First of all speed. Since you are intentionally sending your data half-way around the world before it even gets a chance to head off toward the right server then VPN connection speeds will be slower than your normal, non-VPN connection. Also your VPN provider will only have a certain amount of resources. If the VPN server is overloaded, because there are too many clients and not enough servers, then connections speeds will drop. The same is true for server bandwidth.

VPN會比較慢,因為你的資料要先到VPN伺服器,再到目標伺服器,原本是不用經過VPN伺服器的就會比較快。還有如果VPN伺服器太多使用者,速度就會變慢,就跟普通的伺服器一樣越多人用就會越慢。

Secondly, VPN connections can drop unexpectedly (for a whole variety of reasons) and if you didn’t notice that the VPN is no longer active you might keep using the Internet thinking your privacy is safe, but it isn’t.

還有要注意VPN是不是會斷掉,不然你一直以為你很安全的在上網,實際上VPN已經沒了。

Thirdly, the use of VPNs is outlawed(不合法) in some countries, precisely because they offer anonymity, privacy, and encryption.

在某些國家VPN是不合法的。


上一篇
安裝與設定Ubuntu Server 18.04和安裝Apache
下一篇
AWS EC2 安裝Linux(了解putty、SSH) 和 了解 EC2種類
系列文
Linux學習30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言