跳轉到內容
View in the app

A better way to browse. Learn more.

PHP論壇人

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

主機商分配公網IP、內網IP/私有IP,不能關閉的情況

精選回覆

發表於

-------------------------------------------------------
主機商分配公網IP、內網IP/私有IP,不能關閉的情況
-------------------------------------------------------

阿里雲、騰訊雲等等大廠直接分配公網IP、內網IP/私有IP 不能關閉

在前幾年的IPS論壇會有速度變慢的情況,那時使用CentOS,修改的方法有效

 


最近改用Debian 12,以前CentOS修改的方法不能直接用

不過Debian 12 或 IPS 4.7.x論壇版本,已經不需要以下的方法?


Debian 12修改網路卡配置
vi /etc/network/interfaces

# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

#阿里雲輕量是用dhcp,這裡不用改
auto eth0
iface eth0 inet dhcp

#在這裡,新增一張網路卡,你的伺服器的公網IP
auto eth0:0
iface eth0:0 inet static
address 47.243.x.x
gateway 255.255.255.0
dns-nameservers 8.8.8.8


ESC儲存並離開
:wq

 

 

在前面的教學,我改為安裝軟體防火牆iptables,還有shell防火牆規則

所以再加一個防火牆規則

cd /usr/local/bin

vi firewall-rule-2.sh

 

將以下指令,寫入

#!/bin/sh
iptables -t nat -A POSTROUTING -s 你的伺服器公網IP -j SNAT --to-source=你的伺服器內網IP

 

ESC儲存並離開
:wq

 

r0.png

 

 


變更權限
chmod +x /usr/local/bin/firewall-rule-2.sh

 


修改rc.local
vi /etc/rc.local


將firewall-rule-2.sh 放在 firewall.sh 這一行的下面
/usr/local/bin/firewall-rule-2.sh start

 

r1.png

 

 


ESC儲存並離開
:wq

 

 

重開機
reboot

 

 

查看網路卡,有無公網IP
ifconfig -a

 

那行 47.243.x.x 就是公網IP

r2.png

 

 

查看防火牆規則
iptables-save

 

將顯示前面寫入的那一條防火牆規則 iptables -t nat -A POSTROUTING -s 你的伺服器公網IP -j SNAT --to-source=你的伺服器內網IP
 

r3.png

 

 

再次聲明:有情況才需要做這個修改,沒事就不用改

 

本文章最後於,由Jack編輯

建立帳號或登入後發表意見

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.