2010年12月6日 星期一

Ubunto 10.04 設定固定IP方式

以下是ubuntu固定位址的各項設定:
1. /etc/hosts 加入一行:
192.168.xxx.xxx ubuntu.localhost ubuntu

2. /etc/hosts.allow加入以下設定:
ALL: 192.168.xxx. :allow
sshd: 192.168.xxx.x :allow

3. /etc/hosts.deny加入以下設定:
ALL: deny
sshd: all :deny

4. /etc/network/interfaces加入以下設定:
auto eth0
iface eth0 inet static
address 192.168.xxx.xxx
netmask 255.255.255.xxx
gateway 192.168.xxx.xxx

5. /etc/resolv.conf加入DNS server設定:(以中華電信為例)
nameserver 168.95.192.1
nameserver 168.95.1.1

為盡量達到安全保護的要求,設定一些與SSH有關的值:
1. /etc/ssh/sshd_config裡,更改讓root無法登入(PS:其實現在的ubuntu預設已經沒有root密碼,也就是root已無法登入)
#PermitRootLogin yes
PermitRootLogin no

2. /etc/pam.d/ssh加入以下命令:
auth required pam_listfile.so item=user sense=allow file=/etc/ssh/allow_list onerr=fail

3. 設定允許帳號清單:
a. 加入/etc/ssh/allow_list檔案
b. 加入允許帳號,每個帳號一行

各項設定完畢後,為了防止X-Window底下的網路管理AP與text mode的標準網路設定衝突,依照以下順序啟動網路:
1. 在/etc/NetworkManager/nm-system-settings.conf設定NetworkManager停用:
將 managed=true 改為managed=false

2. 停用NetworkManager
/etc/init.d/network-manager stop
ifdown eth0

3. 啟用networking
/etc/init.d/networking restart

ps: 第一點的"false"設定完後,亦可直接reboot讓ubuntu執行新的設定值

沒有留言:

張貼留言