Massive concrete barriers shield the White House from assailants. A "sniffer" device in the doorway to detect explosives greets visitors to the nation's Capitol. Two 1,300-pound steel doors, complete with bullet-proof peepholes, protect lawmakers in their cloak rooms near the House chamber. And, for the first time in history, when President Reagan is inaugurated Jan. 21, the 140,000 invited guests will be scrutinized by metal detectors.

In government buildings along Pennsylvania Avenue, federal workers will need special one-day passes just to get in to watch the inaugural parade. And they'll view it with this caveat: "If anybody opens a window or steps out on a balcony," authorities told one building administrator, "you can be sure they'll be in somebody's cross hairs."

Now, four years after Ronald Reagan took office, official Washington is protecting itself behind dump trucks set out as barricades and metal detectors that stand like sentries in federal building doorways. It is hard to imagine a president out in the open, walking the 16 blocks from the Capitol to the White House, as Jimmy Carter did on Inauguration Day 1977. But a lot has happened since then.

"In 1983, Americans lost more lives to terrorism than ever before in history," said John M. Walker Jr., the assistant secretary of Treasury who oversees the Secret Service. "While it hasn't reached our shores, it remains a constant concern."

Signs of that concern are everywhere.

At the Pentagon, the underground tunnels where commuters once waited for buses and taxis have been sealed shut, condemned as open invitations to a terrorist's bomb. The State Department has installed an up-to-the-minute "vehicle arrest system" -- steel wedges that protrude from driveways, poised to stop an intruder's speeding truck.

On the Capitol plaza, where there is talk of installing the same system, there's a makeshift measure for now; 24 hours a day, two squad cars sit ready to block any vehicle that runs the security gate houses. Two years ago, the gate houses weren't there.

The barriers are not only physical. Officials are more isolated. Visitors grumble about the inconvenience. Capitol Hill staffers, reporters -- even lobbyists -- have learned, somewhat reluctantly, to wear color-coded badges on chains around their necks. The Capitol Police officers who patrol the grounds have become more wary. "It used to be that you could talk to someone, be relaxed, you know; but now, they could look as normal as you or me, asking questions, laughing, . . . " said one officer. "But these days you never know."

Gone, too, are the days "when you could drive past the Capitol, look at the lighted dome and admire it," Larry E. Smith, the Senate sergeant at arms, said. Now, the Capitol plaza is closed to all cars except those of credentialed reporters and members of Congress.

"There is nothing I'd like more than to have it like it used to be," Smith added. "But that's just not possible." Incidents Provoked Response

What makes it impossible, officials say, is a series of events that took place shortly after Reagan took office.

On March 30, 1981, a revolver-wielding gunman wounded the president outside the Washington Hilton Hotel.

In early December 1981 came word that Libya had sent assassins to murder senior U.S. officials. Only after weeks of alarm were the hit squads said to have disbanded.

Less than two years later, on Oct. 23, 1983, a red pickup truck drove up behind the Marine barracks in Beirut, smashed through a gate and several barriers, and detonated its explosive cargo, killing more than 240 soldiers.

Then on Nov. 7, at about 11 p.m., a powerful bomb exploded on the second floor of the Capitol outside a conference room near the Senate Chamber. The Senate was scheduled to work very late that night, but unexpectedly adjourned at about 7 p.m.

"One would have expected us to be in session," Sen. Daniel Patrick Moynihan (D-N.Y.) recalled last week. The explosion, he said, "went through the plyboard and the glass and would have killed anybody in that room. No question about it."

But the area was deserted, and no one was injured. New paint and plaster and reinforced steel quickly covered the gaping holes. But the scar to the Capitol's traditional openness has not been so quick to heal.

"It changed from one day to the next," said Tom Griscom, an aide to newly retired Senate Majority Leader Howard H. Baker Jr. (R-Tenn.). "There was always activity there in that corridor. . . . The tours went right down the hallway past the Republican leader's office. If the senator was outside the chamber door, tourists would wander through and say, 'There's Howard Baker.' But all that's ended. The day after the bomb, it was quite quiet. It's been that way ever since."

John Jester, the man in charge of security for most of the federal buildings in Washington, traces it all to the bombing in Beirut. "We've had bombings of federal buildings before . . . package bombs that go off in the night. But the Beirut bombing was a new type of threat, someone willing to give their life for the threat. It makes you think, 'How are you going to stop that kind of person?' You have to reexamine how you react. You never sit still and say, 'Okay, we're secure.' "

Then came the Capitol bombing and "reinforced the idea that these things can happen here," said Jester, of the Federal Protective Service for the National Capitol.

Moynihan and other senators, who may argue with the security methods chosen, do not argue with their need.

"Appropriate" is the word Moynihan chooses. "Necessary," said Sen. Jennings Randolph, a West Virginia Democrat who came to Washington in the 1930s, when citizens could stroll across the White House grounds or peer unescorted into its public rooms. "I do not appreciate this garrison state. . . . But we've had two bombings here in the Capitol in the past two years," said Randolph, referring to the 1983 explosion and a firebomb that was thrown on the front steps last summer. "Who knows when the next one will tear the Senate or House chamber apart?"

Nowhere was the change more difficult than at the U.S. Capitol, which James J. Carvino, the new chief of the Capitol Police, calls "the people's building."

"A balance has to be struck to be sure you have the security, but still maintain a climate of freedom," Carvino said last week. "We want to try, but it won't be easy."

Moynihan and others think that goal is far from being met. What's required, said Moynihan, is "architectural barriers" that "do not proclaim your fearfulness."

"A dump truck is not an architectural barrier. A concrete road divider is not. Even when you upturn sewer pipes and plant geraniums in them, that is not an architectural barrier," said Moynihan referring to the round, concrete containers that are now barricading entrances to the Capitol plaza. "They proclaim you are under siege."

But not all the signs of siege are physical. Words such as "magnetometer," the technical term for metal detectors, have crept into the language. At the General Services Administration (GSA), there is an architect whose new speciality is designing aesthetically pleasing planters that can stop a 9-ton truck at 30 miles an hour. Hill receptionists and aides are attending seminars where psychologists from St. Elizabeths Hospital teach them how to deal with disturbed people.

"I keep hearing the term 'fortress America,' " said one GSA official. "Maybe it's true."

The most obtrusive barriers were thrown up last December after authorities received a letter mailed in Manassas detailing an overheard conversation of plans "to blow up" the White House and State Department.

"It came right after the Beirut bombing, and people put more credence in that kind of threat," said Jester.

Suddenly, a company in Midland, Va., that sells 5,000-pound, reinforced concrete barriers got calls from Washington that sounded "urgent," according to one company official. The firm sold 1,500 linear feet of the barricades to the White House and 600 feet more to State.

Sand-filled dump trucks appeared briefly at White House entrances, and the street outside the Old Executive Office Building next to the White House is still torn up by workmen installing crash-proof gates. Lack of Funds Delayed Plans

A Secret Service spokesman said new security measures at the White House had been in the works for several years, but the budget money was not approved. That suddenly changed. "I don't think there's any question that the Beirut bombing was part of the change in chemistry," he said. "Anything that heightens our security needs greases the skids and gets things done."

At about the same time, Delta Scientific Corp., in California, which makes the hydraulically operated steel wedges that "can stop a truck dead," according to its president, found itself with contracts from the Pentagon, the Supreme Court, the National Archives and the State Department.

GSA officials, according to an architect there, are grappling with another problem: "If a terrorist gets within a half block of the building, that's too close. What can we do to stop access?" The agency is looking to expand the perimeters of protection into the neighborhood, the GSA employe said, working with the District government to remove nearby parking meters and restrict the street to official parking.

Still, authorities assert that official Washington is more open than government buildings anywhere in the world. One congressional official is fond of telling the story of the foreign visitors who came to the Capitol, saw only metal detectors at the doorways, and called later to find out "what fabulous state-of-the-art technology we were using."

"They thought all the real security was so sophisticated that it was hidden away," he said. "They were surprised to learn that what they saw is all we have."