Linux Static IP Configuration

 Published: Thursday, July 16th, 2009 by Phil Paradis

By default, Linodes use DHCP to acquire their IP address, routing and DNS information. However, DHCP will only assign one IP to your Linode, so if you have multiple IPs, you’ll need to use a static configuration. Even if you only have one IP, you can still do a static assignment, but it’s not required in most cases.

 Contents

Obtain Networking Info

Before you edit any files, you’ll need to obtain some information. Log into the Linode Manager and click the "Remote Access" tab. You’ll find your IP addresses (both public and private, if you have a private IP assigned), gateways, netmasks and DNS resolvers.

Keep this information handy, because you’ll need to refer to it as you configure your Linode’s network settings. Since Linodes only have one virtual ethernet interface (eth0), you’ll need to assign additional IPs to aliases on that interface. This means you’ll append a colon and a number to the interface name. For these examples, the aliases are numbered in the order they were given, but most outbound connections will originate from the IP assigned to the eth0 interface. If you need server daemons to bind to a particular IP address, you’ll need to specify the correct IP in their configuration files.

Please note that although your VPS may have multiple IP addresses assigned to it, you should only specify a default gateway for one IP. This gateway should be the one that corresponds to the IP address you are setting it on. For example, if you are setting the default gateway for "12.34.56.78" you should use "12.34.56.1" for the gateway.

A default gateway should not be specified for private IP addresses. Additionally, the subnet mask for private IP addresses should be set to "255.255.128.0" (not "255.255.255.0").

Important: You must reboot your Linode after adding an IP address to it before the changes will take effect.

Hostname and FQDN Settings

General Information

If you haven’t already done so, set your system’s hostname and FQDN (fully qualified domain name). Your hostname should be something unique; some people name their systems after planets, others after philosophers, etc. Please note that the system’s hostname has no relationship to websites or email services hosted on it, aside from providing a name for the system itself. Thus, your hostname should not be "www" or anything else too generic.

Debian and Ubuntu

Issue the following commands to set the hostname, replacing "plato" with the hostname of your choice:

echo "plato" > /etc/hostname
hostname -F /etc/hostname

If it exists, edit the file /etc/default/dhcpcd to comment out the "SET_HOSTNAME" directive:

File excerpt:/etc/default/dhcpcd

#SET_HOSTNAME='yes'

Proceed to the section entitled "Update /etc/hosts" to continue.

CentOS/Fedora

Issue the following commands to set the hostname, replacing "plato" with the hostname of your choice:

echo "HOSTNAME=plato" >> /etc/sysconfig/network
hostname "plato"

Proceed to the section entitled "Update /etc/hosts" to continue.

Slackware

Issue the following commands to set the hostname, replacing "plato" with the hostname of your choice:

echo "plato" > /etc/HOSTNAME
hostname -F /etc/HOSTNAME

Proceed to the section entitled "Update /etc/hosts" to continue.

Gentoo

Issue the following commands to set the hostname, replacing "plato" with the hostname of your choice:

echo "HOSTNAME=\"plato\"" > /etc/conf.d/hostname
/etc/init.d/hostname restart

Proceed to the section entitled "Update /etc/hosts" to continue.

Arch

Issue the following commands to set the hostname, replacing "plato" with the hostname of your choice:

echo "HOSTNAME=\"plato\"" > /etc/conf.d/hostname
hostname plato

Proceed to the section entitled "Update /etc/hosts" to continue.

Update /etc/hosts

Next, edit your /etc/hosts file to resemble the following example, replacing "plato" with your chosen hostname, "example.com" with your system’s domain name, and "12.34.56.78" with your system’s IP address. As with the hostname, the domain name part of your FQDN does not necesarily need to have any relationship to websites or other services hosted on the server (although it may if you wish). As an example, you might host "www.something.com" on your server, but the system’s FQDN might be "mars.somethingelse.com."

File:/etc/hosts

127.0.0.1        localhost.localdomain    localhost
12.34.56.78      plato.example.com        plato

The value you assign as your system’s FQDN should have an "A" record in DNS pointing to your Linode’s IP address. For more information on configuring DNS, please see our guide on configuring DNS with the Linode Manager.

DNS Resolver Settings

If you’ve migrated to a new location, you may need to edit your /etc/resolv.conf file so that your Linode can resolve DNS queries. Your nameservers are listed under the "Remote Access" tab. The search and domain lines are optional, but you should definitely include the "options rotate" line.

In the example below, change the IP addresses to reflect the values shown under the "Remote Access" tab of the Linode Manager.

File:/etc/resolv.conf

domain members.linode.com
search members.linode.com
nameserver 98.76.54.32
nameserver 76.54.32.10
options rotate

Static IP Configuration

Debian & Ubuntu

Since Ubuntu is based on Debian, their configuration is the same. The relevant file to edit is /etc/network/interfaces – the file syntax is fairly straightforward, but you can read the comments in the file for more details about what each line does.

In the example below, change the IP addresses to reflect the values shown under the "Remote Access" tab of the Linode Manager.

File:/etc/network/interfaces

# The loopback interface
auto lo
iface lo inet loopback

# Configuration for eth0 and aliases

# This line ensures that the interface will be brought up during boot.
auto eth0 eth0:0 eth0:1

# eth0 - This is the main IP address that will be used for most outbound connections.
# The address, netmask and gateway are all necessary.
iface eth0 inet static
 address 12.34.56.78
 netmask 255.255.255.0
 gateway 12.34.56.1

# eth0:0
# This is a second public IP address.
iface eth0:0 inet static
 address 34.56.78.90
 netmask 255.255.255.0

# eth0:1 - Private IPs have no gateway (they are not publicly routable) so all you need to
# specify is the address and netmask.
iface eth0:1 inet static
 address 192.168.133.234
 netmask 255.255.128.0

Restart networking:

/etc/init.d/networking restart

From the Linode, ping each of the default gateways listed on the "Remote Access" tab of the Linode Manager:

ping 12.34.56.1
ping 98.76.54.1

Once you have confirmed that your networking settings have been correctly configured, issue the following command to uninstall the DHCP client, as it is no longer required.

apt-get remove isc-dhcp-client dhcp3-client dhcpcd

CentOS & Fedora

Note: CentOS & Fedora may include two services to configure networking, and having the wrong one enabled may cause networking to not come up after making these changes. You can check your configuration using these instructions.

CentOS keeps the information for each interface in a separate file named /etc/sysconfig/network-scripts/ifcfg-<interface_alias_name> so you’ll need to create one foreth0 and one for each alias.

In the example below, change the IP addresses to reflect the values shown under the "Remote Access" tab of the Linode Manager.

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

# Configuration for eth0
DEVICE=eth0
BOOTPROTO=none

# This line ensures that the interface will be brought up during boot.
ONBOOT=yes

# eth0 - This is the main IP address that will be used for most outbound connections.
# The address, netmask and gateway are all necessary.
IPADDR=12.34.56.78
NETMASK=255.255.255.0
GATEWAY=12.34.56.1

File:/etc/sysconfig/network-scripts/ifcfg-eth0:0

# Configuration for eth0:0
DEVICE=eth0:0
BOOTPROTO=none

# This line ensures that the interface will be brought up during boot.
ONBOOT=yes

# eth0:0
IPADDR=34.56.78.90
NETMASK=255.255.255.0

File:/etc/sysconfig/network-scripts/ifcfg-eth0:1

# Configuration for eth0:1
DEVICE=eth0:1
BOOTPROTO=none

# This line ensures that the interface will be brought up during boot.
ONBOOT=yes

# eth0:1 - Private IPs have no gateway (they are not publicly routable) so all you need to
# specify is the address and netmask.
IPADDR=192.168.133.234
NETMASK=255.255.128.0

Restart networking:

service network restart

From the Linode, ping each of the default gateways listed on the "Remote Access" tab of the Linode Manager:

ping 12.34.56.1
ping 98.76.54.1

Arch Linux

In the example below, change the IP addresses to reflect the values shown under the "Remote Access" tab of the Linode Manager. All other details should remain the same. The configuration of networking states occurs in the /etc/rc.conf file. Add a hash sign (e.g. #) to the beginning of the existing INTERFACES and eth0 lines to convert them to comments, then add the following lines to your rc.conf file.

File excerpt:/etc/rc.conf

eth0="eth0 12.34.56.78 netmask 255.255.255.0"
eth0_0="eth0:0 21.43.65.87 netmask 255.255.255.0"
eth0_1="eth0:1 192.168.134.241 netmask 255.255.128.0"

INTERFACES=(eth0 eth0_0 eth0_1)

gateway="default gw 12.34.56.1"
ROUTES=(gateway)

In this example, two static public IP addresses are configured on aliases of eth0eth0:0, and eth0:1. Ensure that every interface configuration is included in the INTERFACES list. When you have configured these, issue the following command:

/etc/rc.d/network restart

Due to the way that Arch Linux handles network interfaces, this command will report that the "Stopping the Network Interfaces" operation has failed. When you issue the commandifconfig, you will be able to see the properly configured interfaces.

From the Linode, ping each of the default gateways listed on the "Remote Access" tab of the Linode Manager:

ping 12.34.56.1
ping 98.76.54.1

Gentoo

In the example below, change the IP addresses to reflect the values shown under the "Remote Access" tab of the Linode Manager. You’ll be setting up a static public IP on eth0 and a static private IP on eth0:1. We recommend logging into Lish, since you’ll be restarting the network.

First, open /etc/conf.d/net and comment out your existing config_ethX and routes_ethX lines:

#config_eth0=( "12.34.56.XXX netmask 255.255.255.0" )
#routes_eth0=( "default gw 12.34.56.1" )
#config_eth1=( "192.168.133.XXX netmask 255.255.128.0" )

Using the comments in /etc/conf.d/net.example as your guide, create a new config_eth0 entry that contains both of your addresses in CIDR notation:

config_eth0=(
        "12.34.56.XXX/24"
        "192.168.133.XXX/17"
)

Tip: You can use the free whatmask online tool to get the correct CIDR entry for your netmask.

Now add a new routes_eth0 entry:

routes_eth0=( "default via 12.34.56.1" )

Full example of working /etc/conf.d/net:

config_eth0=(
        "12.34.56.XXX/24"
        "192.168.133.XXX/17"
)

routes_eth0=( "default via 12.34.56.1" )

dns_servers="34.56.78.90 34.56.78.91 34.56.78.92"
dns_search="example.com members.linode.com"
dns_domain="example.com"

Stop your existing eth1 interface and remove it from startup, if applicable:

/etc/init.d/net.eth1 stop
rc-update del net.eth1 default
rm /etc/init.d/net.eth1

Restart networking:

/etc/init.d/net.eth0 restart

From the Linode, ping each of the default gateways listed on the "Remote Access" tab of the Linode Manager:

ping 12.34.56.1
ping 98.76.54.1

OpenSuse

In the example below, change the IP addresses to reflect the values shown under the "Remote Access" tab of the Linode Manager.

File:/etc/sysconfig/network/ifcfg-eth0

# Configuration for eth0
BOOTPROTO='static'

# This line ensures that the interface will be brought up during boot.
STARTMODE='onboot'

# eth0 - This is the main IP address that will be used for most outbound connections.
# The address, netmask and gateway are all necessary. The metric is not necessary but
# ensures you always talk to the same gateway if you have multiple public IPs from
# different subnets.
IPADDR='12.34.56.78'
NETMASK='255.255.255.0'

# eth0:0
# This is a second public IP address.
IPADDR1='34.56.78.90'
NETMASK1='255.255.255.0'
LABEL1='0'

# eth0:1 - Private IP
# Private IP addresses do not have a gateway.
IPADDR2='192.168.133.234'
NETMASK2='255.255.128.0'
LABEL2='1'

Create the following file if necessary:

File/etc/sysconfig/network/routes

# Destination   Gateway                 Netmask                 Device
66.246.75.0     0.0.0.0                 255.255.255.0           eth0
0.0.0.0         12.34.56.1              0.0.0.0                 eth0

Double-check that your /etc/resolv.conf exists and is correct.

Restart networking:

/etc/init.d/network restart

From the Linode, ping each of the default gateways listed on the "Remote Access" tab of the Linode Manager:

ping 12.34.56.1
ping 98.76.54.1
 

php 调用 .net 的 web 服务

 sethm at uoregon dot edu 25-Mar-2008 11:05

Trying to connect to a .NET webservice using the PHP SOAP client, we ran into much strangeness. 

When using __soapCall do:
$params = array('a'=>$a, 'b'=>$b);
$result = $client->__soapCall('someFunction', array($params));

When using calling the function directly use:
$params = array('a'=>$a, 'b'=>$b);
$result = $client->someFunction($params);

If $params isn't associative, the client doesn't form the call correctly. Calling it other ways lead to having the first parameter dropped or the parameters not being displayed in the request.

CentOS 6.0 单cd版

 默认的CentOS 6.0 尺寸是4.4G。国内环境下载都是痛苦的事情,而且有些电脑只有cd光驱。

 所以我们需要 one cd 的 CentOS 6

 http://wiki.centos.org/Manuals/ReleaseNotes/CentOSMinimalCD6.0

 http://lists.centos.org/pipermail/centos-announce/2011-July/017660.html

大陆上amazon购买veer攻略 (转帖)

 当然也可以作为大陆上美国网站购物得教程,本人亲身操作的经历,原创

首先要准备得是一张可以支付美元得信用卡。这里我用得是招行得信用卡。
1.找一家转运公司。经过多方搜索,我选择得是天翼快递。注册之后,会提供你一个美国得收货地址,我在天翼快递公司注册后,提供了我三个地址,我使用得是其中一个免税州得地址。你需要这个地址,因为这是你在amazon购物选择得邮寄地址。天翼快递最近搞活动,首次用户会有折扣。
2.注册amazon,然后选择商品,加入购物车,结账。
选择商品得时候,注意看下对方得信用,销量如何。结账得时候选择信用卡结账,然后你填写你信用卡得信息。这里不需要转到网上银行。我填写得时候,只是写了卡号,持卡人,以及到期日,也没填信用卡密码,然后就支付成功了。这跟国内还不一样。
amazon首次用户可以选择每个月2天得免运费。但是一般人我不推荐弄这个。因为你选择那个服务之后,默认是一直开启得,会每个月从你的信用卡扣钱,需要手工关闭。一般一次运费也就7美元。
支付成功,可以观察order状态,我这里刚开始还能够取消订单。大概1个小时之后,就显示发货了,无法取消订单了。
接下来就时常到amazon查看订单状态,看是否到货。一旦到货,就要马上去天翼快递公司填单子转运了。
我是9.10日下的Amazon订单,9.13日到达天翼快递得美国仓库。登陆天翼快递得网站,会发现仓库到货为1(若没有到货,则为0)。9.13日给天翼快递得帐户充值,1磅4.5美元。他会提示你一个预估值得重量,然后给一个预估值得运费,多退少补。充值后,填运单信息,然后提交。
9.14日开始从天翼快递得仓库发货,9.17日到达上海EMS。9.19日离开上海EMS。
这里面到达上海得时候需要经过海关。我这里没有关税,这个看运气。一般都有关税,手机得费用基本都是150人民币。我这估计不大值钱的手机可能就没收。
商品到手之后,记得上amazon以及天翼快递网站去对收货进行确认,打分等等。

无法将此图像设置为墙纸 出现了一个内部错误 (转帖)

 今天突然发现我的小Y不能更换背景图片,我的电脑的操作系统是win7的旗舰版,具体表现为:1,在桌面空白处点击鼠标右键,选择“下一个桌面背景”,电脑没反应。2,选择一张图片,点击“设为桌面背景”,显示“出现内部错误”不能成功设置.3,在个性化中选择其他主题,电脑有换主题的声音但是桌面背景图片还是没有变化。于是我百度之,现将方法帖出来,希望遇到同样问题的朋友能够看到,节约宝贵的时间。

解决方法为:打开以下路径找到操作系统盘符所在路径,我的是C盘,建议先打开文件夹选项中的操作系统文件夹隐藏保护和显示所有文件夹选项,可以更快的定位文件夹目录。在C:\Users\YourUserName\AppData\Roaming\Microsoft\Windows\Themes,找到TranscodedWallpaper.jpg并删除之,再次切换一个主题就好了。

 来源:http://darinme.net/Working/win7-can-not-change-wallpaper.html