LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Manually set ip-adres (https://www.linuxquestions.org/questions/linux-newbie-8/manually-set-ip-adres-683594/)

jonaskellens 11-15-2008 11:12 AM

Manually set ip-adres
 
In windows I find it very easy to manually set my ip-adres to be in a certain subnet (when I want to be in the same subnet of a router to configure it).

Question : how do I manually set my ip-adres in Fedora9 ? Do I do this by editing /etc/sysconfig/network-scripts/ifcfg-eth0 ??

I am always connected by a wireless connection to my home network 192.168.123.0. When I want to watch the settings of a router (not my own router but one that is connected via ethernet) I do the following :

[root@localhost jonas]# /sbin/ifconfig wlan0 down
[root@localhost jonas]# /sbin/ifconfig eth0 up
[root@localhost jonas]# /sbin/ifconfig eth0 192.168.1.2
[root@localhost jonas]# /sbin/ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:1B:24:A4:B6:06
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::21b:24ff:fea4:b606/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:69 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:13663 (13.3 KiB)
Interrupt:17

[root@localhost jonas]# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
From 192.168.1.2 icmp_seq=2 Destination Host Unreachable
From 192.168.1.2 icmp_seq=3 Destination Host Unreachable
From 192.168.1.2 icmp_seq=4 Destination Host Unreachable
^C
--- 192.168.1.1 ping statistics ---
7 packets transmitted, 0 received, +3 errors, 100% packet loss, time 6468ms
pipe 3

You see that I cannot seem to reach the router (192.168.1.1) that is connected via my eth0-interface.

repo 11-15-2008 11:44 AM

route add default gw 192.168.1.1

jonaskellens 11-15-2008 12:08 PM

Quote:

Originally Posted by repo (Post 3342841)
route add default gw 192.168.1.1

I do not want to set my default gateway cause this means that also my wireless connection will be messed up. And I do not need a default gateway, I do not need to communicate with the outside world...
I just want to manually change my ip-adres to one that I choose.

repo 11-15-2008 12:16 PM

Quote:

I do not want to set my default gateway cause this means that also my wireless connection will be messed up. And I do not need a default gateway, I do not need to communicate with the outside world...
I just want to manually change my ip-adres to one that I choose.
What is the current GW?

pauledwards03 11-15-2008 12:33 PM

If you don't need a default GW you don't need a network :) But if you just want to change your IP address do ifconfig eth0 (whatever interface name) xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx normally the default gw comes after this and you do need it, you could put the IP address of the switch/router that that particular interface is connected to.

I would do this to change my IP address

ifconfig eth0 10.151.35.45 netmask 255.25.240.0 10.151.32.245


I am not sure if you can just leave out the subnet mask and default gw...

jonaskellens 11-15-2008 12:37 PM

Quote:

Originally Posted by repo (Post 3342884)
What is the current GW?

Why do you keep fixing on the default gateway ?
My default gateway (sweex) is 192.168.123.254 for my own home network.
What does the GW have to do with changing my ip-address manually ?
I'm not even on my network when I (try to) connect to the Philips router.

Suppose I want to set up a wireless network from scratch. Then I first need to communicate to the router via a wired interface. If the router has an web-interface that I can reach through 192.168.1.1 than I need to manually put myself in this 192.168.1 -network, right ?
So... does anyone know how to change my ip-adres manually ?

In windows I go to my interface > IPv4 properties > fill in the ip-address...
How does this go in Linux ?

jonaskellens 11-15-2008 12:42 PM

Quote:

Originally Posted by pauledwards03 (Post 3342903)
If you don't need a default GW you don't need a network :) But if you just want to change your IP address do ifconfig eth0 (whatever interface name) xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx normally the default gw comes after this and you do need it, you could put the IP address of the switch/router that that particular interface is connected to.

I would do this to change my IP address

ifconfig eth0 10.151.35.45 netmask 255.25.240.0 10.151.32.245


I am not sure if you can just leave out the subnet mask and default gw...

I think that I'm not obliged to define the subnet mask and default gw because the system can guess the default subnet by looking at the ip-address to know that it is a class A,B or C address.
No gw means no access to the outside world, but that's not necessary.

If you look at my first post you'll see that I allready tried ifconfig eth0 xxx.xxx.xxx.xxx but it did not help in reaching a host on the same network that I'm in then.

repo 11-15-2008 12:44 PM

Quote:

In windows I go to my interface > IPv4 properties > fill in the ip-address...
and the netmask and the default GW

jonaskellens 11-15-2008 12:54 PM

Quote:

Originally Posted by repo (Post 3342916)
and the netmask and the default GW

No, the subnet mask is filled in automatically according to the ip-address that is set. If you want to change the subnet mask, then you can do so.
The default gateway is not necessary, like I already said. I only use 1 internal network.

repo 11-15-2008 12:58 PM

Quote:

No, the subnet mask is filled in automatically according to the ip-address that is set. If you want to change the subnet mask, then you can do so.
The default gateway is not necessary, like I already said. I only use 1 internal network.
So, your ip is 192.168.1.2
netmask is 255.255.255.0
what is your gateway in this case?

cold you give us the output from
/sbin/route -n ?

jschiwal 11-15-2008 01:09 PM

At work, years ago, we were installing new video equipment. I had to switch quickly between two networks, and created an ifcfg-eth0 file for each one, e.g. ifcfg-eth0.adtec & ifcfg-eth0.seachange. Then I created a script that simply copied the one I wanted over the old ifcfg-eth0 file and restarted the network service. In SuSE, the iwcfg-eth0 file is sourced by the ifup-eth0 script. On SuSE, the config file is in /etc/sysconfig/network/, but it may be in a different location on others. For slackware or debian, there may be an /etc/network file that configures networking directly with ifconfig and route commands.

jonaskellens 11-15-2008 01:26 PM

Quote:

Originally Posted by repo (Post 3342935)
So, your ip is 192.168.1.2
netmask is 255.255.255.0
what is your gateway in this case?

cold you give us the output from
/sbin/route -n ?

I don't know what my gateway is. I don't need a gateway. I just want to communicate to a node in the subnet 192.168.1.0. I don't need a gateway 'cause I'm in the same subnet.
I want to access the router via the build-in webinterface that is accessible via the address 192.168.1.1.

What do you do in this setup ???

What I do : I put my pc in the same subnet namely 192.168.1 by manually giving myself the ipaddress 192.168.1.2 or 192.168.1.3 or whatever that's in the same subnet as the client that I want to reach.

When my pc has the ipaddress 192.168.1.2 and the node that I want to reach has the default fixed address 192.168.1.1 then I'm set to communicate.

Same principle as with an APIPA-address !

By editing the /etc/sysconfig/network-scripts/ifcfg-eth0 -file I have now access to the router :

[root@localhost jonas]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Broadcom Corporation NetLink BCM5787M Gigabit Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:1b:24:a4:b6:06
ONBOOT=no
IPADDR=192.168.1.2

Still I don't understand why this did not work in the very beginning...


All times are GMT -5. The time now is 11:04 AM.