CentOS 7  設定PPPOE 固定IP連線

固定IP是架設伺服器不可或缺的設施之一!但是要怎麼使用在CentOS 7 設定固定IP自動連線呢?
在台灣,使用中華電信,可以申請1個固定IP。
方法1:由ISP業者提供固定IP、Gateway、DNS等資訊,直接在CentOS網路組態裡面。
方法2:像中華電信這樣,不會提供固定Gateway等資訊,用戶必須透過PPPOE連線程式連線。

步驟1 : 安裝PPPOE軟體

$ yum install rp-pppoe  

步驟2 : 停止Network Manage

$ systemctl stop NetworkManager.service
$ systemctl disable NetworkManager.service 

步驟 3 : 確認主要的網路裝置名稱

$ sudo ifconfig 

一次列出來好多裝置,怎麼知道我的網路卡是哪一個?
以我的伺服器為例,只有一張網卡,可以看到eth0有MAC address(ether f1:99:f2:88:f3:77)設定值,而且它是有實際傳送與接收資料(RX packets/TX packets)的,所以八九不離十就是他了!

步驟 3 : 開始設定PPPOE軟體

[andy@www~]$ pppoe-setup 

設定PPPOE連線帳號
因為要設定固定,所以要填這個值:Hinet用戶帳號@ip.hinet.net

Welcome to the PPPoE client setup. First, I will run some checks onyour system to make sure the PPPoE client is installed properly… LOGIN NAMEEnter your Login Name (default root): 你的用戶帳號@ip.hinet.net

步驟 3 : 輸入網路卡裝置名稱

INTERFACE Enter the Ethernet interface connected to the PPPoE modemFor Solaris, this is likely to be something like /dev/hme0.For Linux, it will be ethX, where ‘X’ is a number.(default eth0): eth0

Step 3

此處是程式向你詢問,是不是要閒置一段時間就斷線?
如果想要閒置一段時間就斷線,請輸入:閒置秒數。
如果要永遠保持連線狀態,請輸入:NO

Do you want the link to come up on demand, or stay up continuously?If you want it to come up on demand, enter the idle time in secondsafter which the link should be dropped. If you want the link tostay up permanently, enter ‘no’ (two letters, lower-case.)NOTE: Demand-activated links do not interact well with dynamic IPaddresses. You may have some problems with demand-activated links.Enter the demand value (default no): no

Step 4

設定兩組DNS位址,分別是主要(primary)DNS、以及次要(secondary)DNS
下列幾個DNS都可以用:
HiNet提供的DNS:168.95.1.1   168.95.192.1
Google提供的DNS:8.8.8.8    8.8.4.4

Please enter the IP address of your ISP’s primary DNS server.If your ISP claims that ‘the server will provide dynamic DNS addresses’,enter ‘server’ (all lower-case) here.If you just press enter, I will assume you know what you aredoing and not modify your DNS setup.Enter the DNS information here: 168.95.1.1

Please enter the IP address of your ISP’s secondary DNS server.If you just press enter, I will assume there is only one DNS server.Enter the secondary DNS server address here: 8.8.4.4

Step 5

設定連線密碼,這邊就輸入HiNet給的用戶連線密碼:

PASSWORDPlease enter your Password:Please re-enter your Password:

Step 6

使用者控制,是否允許一般使用者操作PPPOE軟體,控制連線或斷線?
預設值是yes
但如果你的伺服器是要提供給其他使者使用,建議設定為no。(例如:伺服器是為了架起來作為電腦課的教學用途)

1234 USERCTRL Please enter ‘yes’ (three letters, lower-case.) if you want to allownormal user to start or stop DSL connection (default yes): yes

Step 7

PPPOE軟體給予的連線模式有三種:
None:一般使用 (我們選擇這個)
Standalone:作為防火牆
Masquerade:作為NAT使用

FIREWALLING Please choose the firewall rules to use.
Note that these rules arevery basic. You are strongly encouraged to use a more sophisticatedfirewall setup; however, these will provide basic security. If youare running any servers on your machine, you must choose ‘NONE’ andset up firewalling yourself. Otherwise, the firewall rules will denyaccess to all standard servers like Web, e-mail, ftp, etc. If youare using SSH, the rules will block outgoing SSH connections whichallocate a privileged source port. The firewall choices are:0 – NONE: This script will not set any firewall rules. You are responsible for ensuring the security of your machine. You are STRONGLY recommended to use some kind of firewall rules.1 – STANDALONE: Appropriate for a basic stand-alone web-surfing workstation2 – MASQUERADE: Appropriate for a machine acting as an Internet gateway for a LANChoose a type of firewall (0-2): 0

Step 8

(電腦)開機時就自動連線?
這邊肯定要設定成自動連線!(y)
但是小心預設值是否喔!(n)

1234 Start this connection at boot time Do you want to start this connection at boot time?Please enter no or yes (default no): y

Step 9

PPPOE軟體會將剛才的設定值列出來給你再次確認:
正確的話就輸入y,即可完成設定!
不正確的話就輸入n,可以更改設定值!

123456789 ** Summary of what you entered ** Ethernet Interface: eth0User name: andyActivate-on-demand: NoDNS: Do not adjustFirewalling: NONEUser Control: yesAccept these settings and adjust configuration files (y/n)? y

Step 10

重啟網路服務!

1 [andy@www~]$ sudo systemctl restart network

恭喜!
到此就算設定完成囉!

https://www.brilliantcode.net/85/centos-7-get-solid-ip-by-pppoe/?cli_action=1638452635.448

安裝時的 Error:

VSFTP 無法取得目錄清單

原來是iptables沒有設定好!解決方法如下:
vi /etc/sysconfig/iptables-config
IPTABLES_MODULES=”ip_nat_ftp ip_conntrack_ftp”# 加入模組即可!兩個模組中間有空白鍵隔開!

 

發佈留言