# Tune CentOS 心得 ###### tags: `CentOS`, `Linux` PS. *\~夜晚的星空~* 原發表於 HiNet Xuite DATE: 02/02/2012 01:34:46 PM 這次是裝6.2-mini-install的版本。 1. 載minimal的版本。 2. 安裝完先用root身份登入,修改網卡設定,改為開機就啟動。 設定檔案 `/etc/sysconfig/network-scripts/ifcfg-eth0`,改 **ONBOOT="yes"** 3. 網卡依照當時情況進行設定。例如要使用 dhcp、固定 IP 或是 PPPoE,IPv6 ...。 參考網址:http://linux.vbird.org/linux_server/0130internet_connect.php * 開機自動DHCP連線: ``` DEVICE=eth0 HWADDR="08:00:27:71:85:BD" NM_CONTROLLED="no" ONBOOT=yes BOOTPROTO=dhcp ``` * 開機自動固定IP連線: ``` DEVICE=eth0 BOOTPROTO=none NM_CONTROLLED=no IPADDR=192.168.1.100 NETMASK=255.255.255.0 ONBOOT=yes ``` 4. 重新啟動網路,`/etc/init.d/network restart`,再 **ifconfig** 看網卡狀況。 5. 修改yum透過proxy連到mirror sites (非必要) * 設定檔案 `/etc/yum.conf`,新增一行 `proxy=http://proxy_ip:port` * 依照 Hinet 的情況是 `proxy=http://proxy.hinet.net:80` 6. 更新系統 `yum update` 7. 裝 telnet client,`yum install telnet` 8. 設定防火牆規則: ``` #!/bin/sh iptables -F iptables -X iptables -Z iptables -P INPUT DROP iptables -P OUTPUT ACCEPT iptables -P FORWARD DROP iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -p tcp --dport 22 -j ACCEPT # For ssh iptables -A INPUT -p tcp --dport 80 -j ACCEPT # For http iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT ``` 將上述的 iptable 規則,寫成一個 shell,再放到 /etc/rc.local 裡。 9. 安裝 sudo: * `yum install sudo` * 用 **visduo** 修改 `/etc/sudoers`,讓 **wheel** 群組的成員可以 sudo 成 root 權限。 ``` ## Allows people in group wheel to run all commands %wheel ALL=(ALL) ALL # <- 拿掉註解 ``` 把要可以sudo的帳號加到wheel群組。 10. 禁止root ssh: 修改 `/etc/ssh/sshd_config` 的 **PermitRootLogin yes** 改為 **PermitRootLogin no** 11. 閹割掉root: 修改 root 登入的 shell 為 **nologin**:修改 `/etc/passwd`
×
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