Use ifconfig-a to view the correct Nic name
# Manually specified Method
################################
# Ipconfig fxp0 192.168.8.33/24 # Add Nic IP Address
# Route add default 192.168.8.1 # Add a route (also known as a gateway)
Takes effect immediately, but becomes invalid after restart.
# It still takes effect after restart
# Ee/etc/rc. conf
Ifconfig_fxp0 = "Inet 192.168.8.8 netmask 255.255.255.0" # Fxp0 NIC address and subnet mask
Defaultrouter = "192.168.8.10" # Gateway address
Hostname = "study.nowire.com.cn" # Machine name
Ifconfig_wi0 = "Inet 192.168.8.55 netmask 255.255.255.0" # Wi0 NIC address, corresponding to wireless Nic
After modifying the/etc/rc. conf configuration, it can take effect as follows:
Method 1: # sh/etc/rc
Method 2: #/etc/netstart
Method 3: restart the machine
# DHCP Mode
################################
Add the following in/etc/rc. conf:
Ifconfig_fxp0 = "DHCP"
You need to specify the NIC name based on the actual situation.
After modifying the/etc/rc. conf configuration, it can take effect as follows:
Method 1: # sh/etc/rc
Method 2: #/etc/netstart
Method 3: restart the machine
#####
DNS Address Configuration
################################
# Ee/etc/resolv. conf
Nameserver 202.96.209.20.
Nameserver 202.96.209.5
Nic control switch
################################
Ifconfig fxp0 up
Ifconfig fxp0 down
#####
# Routing configuration
################################
View routes
Netstat-Rn
Add a route (equivalent to configuring gateway)
Route add default 192.168.8.1 #192.168.8.1 is the gateway address
If you want to modify the current route configuration, You need to delete it and add another one. Of course, if it is not the same name, you can directly add it if it is not the default one.
Route delete default 192.168.8.1
Route add default 192.168.8.10
#####
The following examples are not commonly used.
# DHCP release
################################
# Dhclient-R Release the current lease and exit the client.
Here's a clip of dhclient from the FreeBSD man pages;
"The client normally doesn't release the current lease as it is not required by the DHCP protocol. some cable ISPs require their clients to handle y the server if they wish to release an assigned IP address. the-r flag explicitly releases the current lease, and once the lease has been released, the client exits."
If you are getting kill: xxxx: no such process this means the dhclient process was already stopped
#####
# Specifying an interface to obtain an IP address through DHCP
################################
# Dhclient xl0 Starts the dhclient process for interface xl0
I think its a good idea to specify an interface otherwise you may notice your/var/log/messages filling up with "dhclient: send_packet: address family not supported by protocol family"
Here's a clip of dhclient from the FreeBSD man pages;
"If no interface names are specified on the command line dhclient will normally identify all network interfaces, elimininating non-broadcast interfaces if possible, and attempt to configure each interface ."
#####
# Specify a fixed IP address when an interface fails to be obtained through DHCP.
################################
Method:
Add/etc/dhclient. conf
Alias {
Interface "xl0 ";
Fixed-address 192.168.42.40;
Option subnet-mask limit 255.0;
}
Example:
# Ee/etc/dhclient. conf
# $ FreeBSD: src/etc/dhclient. conf, V 1.2.2.1 2001/12/14 11:44:31 rwatson exp $
#
# This file is required by the isc dhcp client.
# See ''man 5 dhclient. conf'' for details.
#
# In most cases an empty file is sufficient for most people as
# Defaults are usually fine.
#
Alias {
Interface "xl0 ";
Fixed-address 192.168.42.40;
Option subnet-mask limit 255.0;
}
In the above example, when the dhclient cannot obtain the IP address through the DHCP server, it uses the fixed IP address 192.168.42.40.