配置ssh/IP/fw/xhost

cccgw發表於2008-05-04

配置ssh/IP/防火牆

/etc/rc.d/init.d/sshd start

/etc/sysconfig/network-scripts/ifcfg-eth0

service iptables stop --停止

[@more@]

安裝linux的時候,ssh自帶的也給安裝上了,但並不能直接使用,還需要啟用:

啟用ssh:
/etc/rc.d/init.d/sshd start
service sshd start
netstat -tl

啟用以後,每次開機還都得重新啟用。

可以在啟動linux時自動啟動ssh:
在檔案/etc/rc2.d/S99local裡面加入 /usr/sbin/sshd &
(/usr/sbin/sshd 是ssh啟動的)

這樣每次開機以後就不用再次啟用,直接就可以遠端控制。

xhost 是用來控制X server訪問許可權的。 如使用VNC等工具連Linux時,通常當你從hostA登陸到hostB上執行hostB上的應用程式時, 需要在hostB上以root使用者執行xhost + 來使其它使用者能夠訪問hostB的Xserver.

xhost + 是使所有使用者都能訪問Xserver.
xhost + ip使ip上的使用者能夠訪問Xserver.
xhost + nis:user@domain使domain上的nis使用者user能夠訪問
xhost + inet:user@domain使domain上的inet使用者能夠訪問。

防火牆

linux 下修改防火牆配置需要修改 /etc/sysconfig/iptables 這個檔案,如果要開放哪個埠,在裡面新增一條
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT就可以了,其中 1521 是要開放的埠號,然後重新啟動linux的防火牆服務。
停止/啟動防火牆服務的命令:
用root登入後,執行
service iptables stop --停止
service iptables start --啟動
(service命令位於/sbin)

防火牆規則只有在 iptables 服務執行的時候才能被啟用。要手工啟動服務,使用以下命令:
/sbin/service iptables restart
要確保它在系統引導時啟動,使用以下命令:
/sbin/chkconfig --level 345 iptables on
ipchains 服務不能和 iptables 服務同時執行。要確定 ipchains 服務被禁用,執行以下命令:
/sbin/chkconfig --level 345 ipchains off


配置IP地址:
/etc/sysconfig/network-scripts/ifcfg-eth0

裡面的內容:
[root@localhost network-scripts]# cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=192.168.0.2
USERCTL=no
PEERDNS=yes
GATEWAY=192.168.0.1

配置完以後:
 /etc/init.d/network reload 或 service network

檢視網路卡資訊: route -n檢視物理網路卡:mii-tool重啟eth0: ifup eth0檢視eth0信

息:ethtool eth0新增IP地址:ifconfig eth0 IP netmask 子網掩碼 broadcast 廣播地址

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/668365/viewspace-1003303/,如需轉載,請註明出處,否則將追究法律責任。

相關文章