|
藍森林 http://www.lslnet.com 2006年8月18日 15:18
如何才能自動獲得eth0ip地址
我在網上下載了一個屏蔽端口的自啟動程序,自己做了適當的修改;裡面有IPADDR="<IPADDR>;" 這麼一行(下面顯示紅色)。有沒有什麼辦法,能讓其自動獲得eth0的IP地址?諸如讓IPADDR="202.115.18.111"。 或者是用什麼命令來執行?
請諸位大俠幫忙
## ============================================================
#!/bin/bash
#
# Load appropriate modules.
modprobe ip_tables
modprobe ip_conntrack
modprobe ip_conntrack_ftp
# These lines are here in case rules are already in place and the script is ever rerun on the fly.
# We want to remove all rules and pre-exisiting user defined chains and zero the counters
# before we implement new rules.
iptables -F
iptables -X
iptables -Z
# Set up a default DROP policy for the built-in chains.
# If we modify and re-run the script mid-session then (because we have a default DROP
# policy), what happens is that there is a small time period when packets are denied until
# the new rules are back in place. There is no period, however small, when packets we
# don't want are allowed.
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
## ===========================================================
## Some definitions:
IFACE="eth0"
[color=red]IPADDR="<IPADDR>;" [/color]
NAMESERVER_1="202.96.209.5"
NAMESERVER_2="61.134.1.4"
BROADCAST="192.168.1.255"
LOOPBACK="127.0.0.0/8"
CLASS_A="10.0.0.0/8"
CLASS_B="172.16.0.0/12"
CLASS_MINE="192.168.1.0/24"
CLASS_C="192.168.0.0/16"
CLASS_D_MULTICAST="224.0.0.0/4"
CLASS_E_RESERVED_NET="240.0.0.0/4"
P_PORTS="0:1023"
UP_PORTS="1024:65535"
TR_SRC_PORTS="32769:65535"
TR_DEST_PORTS="33434:33523" |
如何才能自動獲得eth0ip地址
置頂的一句話裡就有這個命令啊。 |
如何才能自動獲得eth0ip地址
| 如何才能自動獲得eth0ip地址
ifconfig eth0 |awk '/inet addr/ {split($2,x,":");print x[2]}' |
如何才能自動獲得eth0ip地址
ifconfig eth0|awk -F"[ :]" '/inet/{print $13}' |
如何才能自動獲得eth0ip地址
| 如何才能自動獲得eth0ip地址
ifconfig eth0 | awk '/inet/{print $2}' | awk -F: '{print $2}' |
| |