# (二)網路設定 ## server端   點選剛建立的網路內容,將IPV4的IP改為: **<font color="red">172.24.10.1</font>**  啟用伺服器        :::info 進到虛擬機內先用``ifconfig``查看網路是不是有兩張卡,並確認網卡名稱 (通常對外是192,對內有改過會是172) ::: 設定網卡IP的內容 ``` $ vim /etc/sysconfig/network-scripts/ifcfg-enp0s3 (設定對外的) ``` ```dockerfile= #執行結果 #新增或修改檔案,加入以下內容 BOOTPROTO=static ONBOOT=yes IPADDR=192.168.1.3 GATEWAY=192.168.1.1 ``` ``` $ vim /etc/sysconfig/network-scripts/ifcfg-enp0s8 (設定對內的) ``` 如果沒有的話就複製enp0s3的內容過去 ```dockerfile= #執行結果 #新增或修改檔案,加入以下內容 BOOTPROTO=static ONBOOT=yes IPADDR=172.24.10.8 GATEWAY=172.24.10.1 ``` :::info 好了之後先``Reboot``一次 重開機完 用``Route -n``查看gateway有沒有設好 ::: ### ipforward ``` $ vim /etc/stsctl.conf ``` ```dockerfile= #執行結果 #在檔案中新增下面這行 net.ipv4.ip forward=1 ``` 使其生效 ``` $ sysctl -p ``` ## client端 :::info 主要是跟SERVER的對內網卡設定一樣,主要是差在只有用一張僅限主機的網卡 ::: ### KVM8 ``` $ vim /etc/sysconfig/network-scripts/ifcfg-enp0s3 ``` ```dockerfile= #執行結果 #新增或修改檔案,加入以下內容 ONBOOT=yes IPADDR=172.24.10.3 GATEWAY =172.24.10.1 ``` ### KVM10 ``` $ vim /etc/sysconfig/network-scripts/ifcfg-enp0s3 ``` ```dockerfile= #執行結果 #新增或修改檔案,加入以下內容 ONBOOT=yes IPADDR=172.24.10.5 GATEWAY =172.24.10.1 ``` :::danger 改完記得``REBOOT`` client重開機後要跟server互ping看能不能通 :::
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up