Ifconfig

From Noah.org
Revision as of 19:52, 3 September 2008 by Root (talk | contribs) (→‎Virtual Interfaces)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Set static IP

These settings are lost on reboot. This is just for a temporary config.

# ip route add default via 192.168.0.1
# ifconfig eth0 192.168.0.2 netmask 255.255.255.0

Virtual Interfaces

Adding virtual interfaces is easy in Linux. Just add a number to a real interface name. In this example, I assume 'eth0' is the real interface name, so I will configure 'eth0:1' (you can pick any free number after the 'eth0:'). The netmask defaults to 255.255.255.0.

ifconfig eth0:1 192.168.0.3

If you need to specify the netmask, this is easy:

ifconfig eth0:1 192.168.0.3 netmask 255.255.255.128

Delete an interface

Use the 'down' command:

# ifconfig eth0:1 down