Rather than setting the IPs manually, you can add an alias on the fly.
If you run the ifconfig command, it will display your current IP.
- Code: Select all
ifconfig
The output will look something like this
- Code: Select all
eth0 Link encap:Ethernet HWaddr 00:0f:fe:46:12:34
inet addr:192.168.0.10 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20f:feff:fe46:6203/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:17694 errors:0 dropped:0 overruns:0 frame:0
TX packets:5986 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1722566 (1.7 MB) TX bytes:3282006 (3.2 MB)
Interrupt:17
You will see the IP address next to the entry that says "inet addr".
if you have root access you can run the following command to add an alias "eth0:1" to the current "eth0".
- Code: Select all
ifconfig eth0:1 192.168.50.10
This will add the alias "eth0:1" and assign the IP address 192.168.50.10 to it.
When you now run "ifconfig" you will see an additional interface entry with the new IP.
- Code: Select all
eth0:1 Link encap:Ethernet HWaddr 00:0f:fe:46:62:03
inet addr:192.168.50.10 Bcast:192.168.50.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:17
You can now access other PCs on your local LAN that has n IP in the 192.168.50.* range.
To remove the alias again, you can run the following command.
- Code: Select all
ifconfig eth0:1 down
NOTE:Be very carefull with this command since you could bring down the entire network connection for the server, if you misspell this command.