3.1.2 IP Configuration

Use this command to configure the IP basic settings, control IP interfaces, and IP routes. The maximum number of interfaces supported is 8, and the maximum number of routes is 32.

Command Syntax:

ip name-server [ <order> ] { <v_ipv4_ucast> | { <v_ipv6_ucast> [ interface vlan <v_vlan_id_static> ] | dhcp [ ipv4 | ipv6 ] [ interface vlan <v_vlan_id_dhcp> ] }
ip dns proxy 
Table 3-2. Command Description

Argument

Description

Parameter

<order>

Preference of DNS server. The default selection is 0.

<v_ipv4_ucast>

A valid IPv4 unicast address

<v_ipv6_ucast>

A valid IPv6 unicast address

dhcp

Dynamic Host Configuration Protocol

Default

No DNS server configured

Mode

Global Configuration mode

Usage

Set the DNS for resolving domain names. To return to the default, use the 'no' version of the command. When the DNS proxy is required, use the command to enable the DNS proxy service.

Example

Example 1:

DNS Server 0 setting is derived from any DHCPv4 VLANs-ID.

(config)# ip name-server 0 dhcp 

Example 2:

DNS Server 1 configured as a static IPv4 address.

(config)# ip name-server 1 192.168.0.10 

Example 3:

DNS Server 1 setting is derived from DHCPv4 VLANs-ID1.

(config)#ip name-server 1 dhcp ipv4 interface vlan 1 

Use this command to add IPv4, IPv6 interface.

Command Syntax:

ip address { { <address> <netmask> } | { dhcp [ fallback <fallback_address> <fallback_netmask> [ timeout <fallback_timeout> ] ] [ client-id { <port_type> <client_id_interface> | ascii <ascii_str> | hex <hex_str> } ] [ hostname <hostname> ] } }
ipv6 address <subnet>
ipv6 address { autoconfig | dhcp [ rapid-commit ] }
Table 3-3. Command Description

Argument

Description

Parameter

<address>

IPv4 address

<netmask>

IP netmask

dhcp

Enable Dynamic Host Configuration Protocol

fallback

DHCP fallback settings

client-id

DHCP client identifier

hostname

DHCP host name

<subnet>

IPv6 prefix x:x::y/z

autoconfig

Enable IPv6 Stateless Auto-configuration

rapid-commit

Enable DHCPv6 client Rapid-Commit option

Default

N.A

Mode

VLAN Interface Configuration mode

Usage

Add VLAN interface and set all IPv4, IPv6 parameters. To disable the selected VLAN interface, use the ‘no’ version of the command. To remove it completely, use no interface vlan <id> from Global Configuration mode.

Example

Example 1:

Set VLAN2 static IP address to 192.168.1.50 mask length 24.

(config)#interface vlan 2
(config-if-vlan)# ip address 192.168.1.50 255.255.255.0 

Example 2:

Add VLAN 3 and set it to get IP address from DHCP using MAC of port 1 as Client ID with a hostname "test".

(config)#interface vlan 3
(config-if-vlan)# ip address dhcp client-id GigabitEthernet 1/1 hostname test

Use this command to add new IP route.

Command Syntax:

ip route <v_ipv4_addr> <v_ipv4_netmask> { <v_ipv4_gw> | blackhole } [ distance <v_distance> ]
Table 3-4. Command Description

Argument

Description

Parameter

<v_ipv4_addr>

Network

<v_ipv4_netmask>

Netmask

<v_ipv4_gw>

Gateway

blackhole

Create a blackhole route (all traffic to the network is discarded)

<v_distance>

Distance value for this route

Default

N.A

Mode

Global Configuration mode

Usage

To route all unknown destination IPs to default gateway, use the following parameters: Network = 0.0.0.0, Netmask = 0.0.0.0, and Distance = 1. To remove the route, use no ip route command with all parameters for the selected route.

Example

Example 1:

Add IP route to gateway 192.168.1.1.

(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.1 1

Example 2:

Remove IP route.

(config)#no ip route 0.0.0.0 0.0.0.0 192.168.1.1