Difference between revisions of "Ifconfig"
From Noah.org
Jump to navigationJump to search(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | [[Category:Engineering]] | ||
+ | [[Category: Networking]] | ||
== Set static IP == | == Set static IP == | ||
− | <pre>ifconfig eth0 192.168.0.2 netmask 255.255.255.0</pre> | + | |
+ | These settings are lost on reboot. This is just for a temporary config. | ||
+ | |||
+ | <pre> | ||
+ | # ip route add default via 192.168.0.1 | ||
+ | # ifconfig eth0 192.168.0.2 netmask 255.255.255.0 | ||
+ | </pre> | ||
== Virtual Interfaces == | == Virtual Interfaces == | ||
− | + | ||
− | <pre>ifconfig eth0:1 192.168.0.3 netmask 255.255.255. | + | 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. |
+ | |||
+ | <pre> | ||
+ | ifconfig eth0:1 192.168.0.3 | ||
+ | </pre> | ||
+ | |||
+ | If you need to specify the netmask, this is easy: | ||
+ | |||
+ | <pre> | ||
+ | ifconfig eth0:1 192.168.0.3 netmask 255.255.255.128 | ||
+ | </pre> | ||
+ | |||
+ | == Delete an interface == | ||
+ | Use the 'down' command: | ||
+ | <pre># ifconfig eth0:1 down</pre> |
Latest revision as of 19:52, 3 September 2008
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