≡ Menu

network interface

Debian / Ubuntu Linux Setting a Default Gateway

Q. How do I setup a default gateway on Debian or Ubuntu Linux? My router IP is and I'd like to setup this as a default gateway for Debian Linux.

A. You can use command line tool such as
a] ip command - show / manipulate routing, devices, policy routing and tunnels

b] route command - show / manipulate the IP routing table

c] Save routing information to a configuration file so that after reboot you get same default gateway.

ip command to set a default router to

Login as the root and type:
# ip route add default via
$ sudo ip route add default via

route command to set a default router to

Login as the root and type:
# route add default gw
$ sudo route add default gw

Save routing information to a configuration file /etc/network/interfaces

Open /etc/network/interfaces file
# vi /etc/network/interfaces
$ sudo vi /etc/network/interfaces
Find eth0 or desired network interface and add following option
Save and close the file. Restart networking:
# /etc/init.d/networking restart
$ sudo /etc/init.d/networking restart

Linux change ip address

Q. How do I change ip address in Linux?

A. There are different ways to change IP address in Linux
(a) Command Line tools

(b) Modify configuration files

(c) Use GUI tools

Task: Display current IP address and setting for network interface called eth0

Use ifconfig command:
# ifconfig eth0

eth0      Link encap:Ethernet  HWaddr 00:30:48:5A:BF:46
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::230:48ff:fe5a:bf46/64 Scope:Link
          RX packets:728204 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1097451 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:62774749 (59.8 MiB)  TX bytes:1584343634 (1.4 GiB)

Task: Change IP address

You can change ip address using ifconfig command itself. To set IP address, enter command:
# ifconfig eth0 netmask up
# ifconfig eth0

To make permanent changes to IP address you need to edit configuration file according to your Linux distribution.

Change IP address under RedHat / CentOS / Fedora core Linux

=> Please read - Howto change and setup IP address in Redhat Linux

Change IP address under Debian / Ubuntu Linux

=> Please read - Howto change and setup IP address in Ubuntu / Debian based Linux distros

Linux Creating or Adding New Network Alias To a Network Card (NIC)

Q. I would like to create alias for my network card (NIC). How do I setup 2 IP address on One NIC? How do I add alias under Centos / Fedora / Debian / Ubuntu Linux?
[click to continue…]

Iptables Open FTP Port 21 and 20

How do I open port 21 using Linux iptables firewall?
[click to continue…]

Commonly used UNIX / Linux commands by new user

Q. . I'm a new Linux user. Can you tell me commonly used Linux / UNIX command?
[click to continue…]