「HowTo] LAN内のProftpdサーバをグローバルに公開する
2013年3月3日LAN内のFTPサーバをグローバルに公開しなければならなかったので、その手順。
環境はCTUにグローバルIPがあたっていて、LAN内にはルータはない(多段ルータ環境ではない)前提のメモ。
- Proftpdの設定
Proftpdの設定を以下のように変更
※あくまでサンプルなので、そのまま使用しないこと!
ServerName "ProFTPD server" ServerIdent on "FTP Server ready." ServerAdmin root@localhost ServerType standalone DefaultServer on AccessGrantMsg "User %u logged in." DeferWelcome off DefaultRoot ~ !wheel DefaultRoot / wheel AuthPAMConfig proftpd AuthOrder mod_auth_pam.c* mod_auth_unix.c IdentLookups off UseReverseDNS off Port 21 # 適宜変更 Umask 022 ListOptions "-a" AllowRetrieveRestart on AllowStoreRestart on MaxInstances 20 User nobody Group nobody UseSendfile no ScoreboardFile /var/run/proftpd.score <Global> AllowOverwrite yes <Limit ALL SITE_CHMOD> AllowAll </Limit> </Global> LogFormat allinfo "%t : %u (%a [%h]) : [%s], %T, %m (%f)" LogFormat write "%t : %u : %F (%a)" LogFormat read "%t : %u : %F (%a)" LogFormat auth "%t : %u (%a [%h])" ExtendedLog /var/log/proftpd/all.log ALL allinfo ExtendedLog /var/log/proftpd/write.log WRITE write ExtendedLog /var/log/proftpd/read.log READ read ExtendedLog /var/log/proftpd/auth.log AUTH auth ServerLog /varlog/proftpd/proftpd.log TLSEngine on TLSRequired off TLSRSACertificateFile /etc/pki/tls/certs/proftpd.pem TLSRSACertificateKeyFile /etc/pki/tls/certs/proftpd.pem TLSCipherSuite ALL:!ADH:!DES TLSOptions NoCertRequest TLSVerifyClient off TLSLog /var/log/proftpd/tls.log <Limit Login> Order allow,deny Allow from 127.0.0.1,192.168.1.0/24 # 適宜変更 Deny all </Limit> PassivePorts 10000 10020 # 適宜変更 MasqueradeAddress hoge.com # 適宜変更 SetEnv TZ JST-9
今回は、固定IPの為standaloneモードで起動。動的IPの場合は、IPが書き換えられないので、xinetd経由で起動すること。
設定ファイルを保存後、サービスをリスタート
- CTU::IPアドレスの払い出し
CTUから、Linuxサーバ(Proftpd)向けにNATを設定
まずは、IPアドレスの払い出し。この設定を忘れるとグローバルに公開できない(必須)らしい。
やり方は、MACアドレスに対してローカルIPアドレス(xx.xx.xx.xx)を割り当ててあげるだけ。CTUにこんな機能があるとは知らなかった。(通常は、Linuxサーバは固定のプライベートIPで運用するので、ここではそのIPを指定しておく)
- CTU::ポート変換(NAT)
次に、ポート変換。
ここでは、Proftpdのconfigで指定したPort 21番を割り当てる。
例:
Port: 21 Protcol: TCP IP: xx.xx.xx.xx
- CTU::ファイアウォール
最後に、CTUのファイアウォールの設定を変更。
この場合、20番、21番、10000~10010番を公開。
接続先のリモートIPが固定ならば、よりセキュアに設定できる
- 確認
1~4までの設定が完了したら、FilezillaなどのFTPクライアントから接続して確認する。
TLSRequiredをonにしていると、FTPS(FTP over SSL/TLS)のみの接続となる。